fix: correct tabby-webserver validation logic (#953)
parent
7de4073779
commit
5cbb2b3a4c
|
|
@ -191,9 +191,11 @@ fn from_validation_errors<S: ScalarValue>(error: ValidationErrors) -> FieldError
|
||||||
obj.into()
|
obj.into()
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut ext = Object::with_capacity(2);
|
let mut error = Object::with_capacity(1);
|
||||||
ext.add_field("code", Value::scalar("validation-error".to_string()));
|
error.add_field("errors", Value::list(errors));
|
||||||
ext.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())
|
FieldError::new("Invalid input parameters", ext.into())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,17 @@ struct RegisterInput {
|
||||||
code = "password1",
|
code = "password1",
|
||||||
message = "Password must be at most 20 characters"
|
message = "Password must be at most 20 characters"
|
||||||
))]
|
))]
|
||||||
#[validate(must_match(
|
|
||||||
code = "password1",
|
|
||||||
message = "Passwords do not match",
|
|
||||||
other = "password2"
|
|
||||||
))]
|
|
||||||
password1: String,
|
password1: String,
|
||||||
#[validate(length(
|
#[validate(length(
|
||||||
min = 8,
|
min = 8,
|
||||||
code = "password2",
|
code = "password2",
|
||||||
message = "Password must be at least 8 characters"
|
message = "Password must be at least 8 characters"
|
||||||
))]
|
))]
|
||||||
|
#[validate(must_match(
|
||||||
|
code = "password2",
|
||||||
|
message = "Passwords do not match",
|
||||||
|
other = "password1"
|
||||||
|
))]
|
||||||
#[validate(length(
|
#[validate(length(
|
||||||
max = 20,
|
max = 20,
|
||||||
code = "password2",
|
code = "password2",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue