fix: correct tabby-webserver validation logic (#953)

support-auth-token
Meng Zhang 2023-12-06 22:38:04 +08:00 committed by GitHub
parent 7de4073779
commit 5cbb2b3a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -191,9 +191,11 @@ fn from_validation_errors<S: ScalarValue>(error: ValidationErrors) -> FieldError
obj.into()
})
.collect::<Vec<_>>();
let mut ext = Object::with_capacity(2);
ext.add_field("code", Value::scalar("validation-error".to_string()));
ext.add_field("errors", Value::list(errors));
let mut error = Object::with_capacity(1);
error.add_field("errors", Value::list(errors));
let mut ext = Object::with_capacity(1);
ext.add_field("validation-errors", error.into());
FieldError::new("Invalid input parameters", ext.into())
}

View File

@ -38,17 +38,17 @@ struct RegisterInput {
code = "password1",
message = "Password must be at most 20 characters"
))]
#[validate(must_match(
code = "password1",
message = "Passwords do not match",
other = "password2"
))]
password1: String,
#[validate(length(
min = 8,
code = "password2",
message = "Password must be at least 8 characters"
))]
#[validate(must_match(
code = "password2",
message = "Passwords do not match",
other = "password1"
))]
#[validate(length(
max = 20,
code = "password2",