diff --git a/ee/tabby-webserver/src/schema/auth.rs b/ee/tabby-webserver/src/schema/auth.rs index 22ba632ef531..864c49e0ae0f 100644 --- a/ee/tabby-webserver/src/schema/auth.rs +++ b/ee/tabby-webserver/src/schema/auth.rs @@ -251,13 +251,13 @@ impl relay::NodeType for User { #[derive(Validate, GraphQLInputObject)] pub struct RequestInvitationInput { - #[validate(email(code = "email"))] + #[validate(email(code = "email", message = "Invalid email address"))] pub email: String, } #[derive(Validate, GraphQLInputObject)] pub struct RequestPasswordResetEmailInput { - #[validate(email(code = "email"))] + #[validate(email(code = "email", message = "Invalid email address"))] pub email: String, } diff --git a/ee/tabby-webserver/src/schema/constants.rs b/ee/tabby-webserver/src/schema/constants.rs index 412b6c16af16..7a0cffcc91a3 100644 --- a/ee/tabby-webserver/src/schema/constants.rs +++ b/ee/tabby-webserver/src/schema/constants.rs @@ -2,5 +2,5 @@ use lazy_static::lazy_static; use regex::Regex; lazy_static! { - pub static ref REPOSITORY_NAME_REGEX: Regex = Regex::new("^[\\w-]+$").unwrap(); + pub static ref REPOSITORY_NAME_REGEX: Regex = Regex::new("^[a-zA-Z][\\w.-]+$").unwrap(); } diff --git a/ee/tabby-webserver/src/schema/email.rs b/ee/tabby-webserver/src/schema/email.rs index 2f529d2633c2..1f314564562f 100644 --- a/ee/tabby-webserver/src/schema/email.rs +++ b/ee/tabby-webserver/src/schema/email.rs @@ -32,7 +32,7 @@ pub struct EmailSetting { #[derive(GraphQLInputObject, Validate)] pub struct EmailSettingInput { pub smtp_username: String, - #[validate(email(code = "fromAddress"))] + #[validate(email(code = "fromAddress", message = "Invalid email address"))] pub from_address: String, pub smtp_server: String, pub smtp_port: i32, diff --git a/ee/tabby-webserver/src/schema/types.rs b/ee/tabby-webserver/src/schema/types.rs index caff9449b590..5217df8a0d1e 100644 --- a/ee/tabby-webserver/src/schema/types.rs +++ b/ee/tabby-webserver/src/schema/types.rs @@ -5,10 +5,11 @@ use validator::Validate; pub struct CreateRepositoryProviderInput { #[validate(regex( code = "displayName", - path = "crate::schema::constants::REPOSITORY_NAME_REGEX" + path = "crate::schema::constants::REPOSITORY_NAME_REGEX", + message = "Invalid repository provider name" ))] pub display_name: String, - #[validate(length(code = "access_token", min = 10))] + #[validate(length(code = "accessToken", min = 10, message = "Invalid access token"))] pub access_token: String, } @@ -17,10 +18,11 @@ pub struct UpdateRepositoryProviderInput { pub id: ID, #[validate(regex( code = "displayName", - path = "crate::schema::constants::REPOSITORY_NAME_REGEX" + path = "crate::schema::constants::REPOSITORY_NAME_REGEX", + message = "Invalid repository provider name" ))] pub display_name: String, - #[validate(length(code = "access_token", min = 10))] + #[validate(length(code = "accessToken", min = 10, message = "Invalid access token"))] pub access_token: String, } diff --git a/rules/validate-requires-code.yml b/rules/validate-requires-code.yml index 166fc6985aa1..19fb0f88c0c2 100644 --- a/rules/validate-requires-code.yml +++ b/rules/validate-requires-code.yml @@ -1,17 +1,21 @@ id: validate-requires-code -message: Validations requires code being set for frontend error display +message: Validations requires code / message being set for frontend error display severity: error language: rust files: -- ./ee/tabby-webserver/src/** + - ./ee/tabby-webserver/src/** rule: all: - - pattern: '#[validate]' + - pattern: "#[validate]" - not: - has: - stopBy: end - pattern: code + all: + - has: + stopBy: end + pattern: code + - has: + stopBy: end + pattern: message - not: has: stopBy: end - pattern: custom \ No newline at end of file + pattern: custom