Follow API change of validator

This commit is contained in:
Kitaiti Makoto 2022-01-07 04:55:49 +09:00
parent 237da47950
commit 800e74da67
6 changed files with 15 additions and 17 deletions

View File

@ -7,8 +7,6 @@ extern crate gettext_macros;
extern crate rocket;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate validator_derive;
use clap::App;
use diesel::r2d2::ConnectionManager;

View File

@ -23,7 +23,7 @@ use plume_models::{
#[derive(Default, FromForm, Debug, Validate)]
pub struct NewCommentForm {
pub responding_to: Option<i32>,
#[validate(length(min = "1", message = "Your comment can't be empty"))]
#[validate(length(min = 1, message = "Your comment can't be empty"))]
pub content: String,
pub warning: String,
}

View File

@ -20,7 +20,7 @@ use validator::{Validate, ValidationError, ValidationErrors};
#[derive(Default, FromForm, Validate)]
#[validate(schema(
function = "emails_match",
skip_on_field_errors = "false",
skip_on_field_errors = false,
message = "Emails are not matching"
))]
pub struct EmailSignupForm {
@ -41,15 +41,15 @@ fn emails_match(form: &EmailSignupForm) -> Result<(), ValidationError> {
#[derive(Default, FromForm, Validate)]
#[validate(schema(
function = "passwords_match",
skip_on_field_errors = "false",
skip_on_field_errors = false,
message = "Passwords are not matching"
))]
pub struct NewUserForm {
#[validate(length(min = "1", message = "Username should be at least 1 characters long"))]
#[validate(length(min = 1, message = "Username should be at least 1 characters long"))]
pub username: String,
#[validate(length(min = "8", message = "Password should be at least 8 characters long"))]
#[validate(length(min = 8, message = "Password should be at least 8 characters long"))]
pub password: String,
#[validate(length(min = "8", message = "Password should be at least 8 characters long"))]
#[validate(length(min = 8, message = "Password should be at least 8 characters long"))]
pub password_confirmation: String,
pub email: String,
pub token: String,

View File

@ -73,12 +73,12 @@ pub fn admin_mod(_mod: Moderator, conn: DbConn, rockets: PlumeRocket) -> Ructe {
#[derive(Clone, FromForm, Validate)]
pub struct InstanceSettingsForm {
#[validate(length(min = "1"))]
#[validate(length(min = 1))]
pub name: String,
pub open_registrations: bool,
pub short_description: SafeString,
pub long_description: SafeString,
#[validate(length(min = "1"))]
#[validate(length(min = 1))]
pub default_license: String,
}

View File

@ -37,9 +37,9 @@ pub fn new(m: Option<String>, conn: DbConn, rockets: PlumeRocket) -> Ructe {
#[derive(Default, FromForm, Validate)]
pub struct LoginForm {
#[validate(length(min = "1", message = "We need an email, or a username to identify you"))]
#[validate(length(min = 1, message = "We need an email, or a username to identify you"))]
pub email_or_name: String,
#[validate(length(min = "1", message = "Your password can't be empty"))]
#[validate(length(min = 1, message = "Your password can't be empty"))]
pub password: String,
}
@ -193,7 +193,7 @@ pub fn password_reset_form(
#[derive(FromForm, Default, Validate)]
#[validate(schema(
function = "passwords_match",
skip_on_field_errors = "false",
skip_on_field_errors = false,
message = "Passwords are not matching"
))]
pub struct NewPasswordForm {

View File

@ -399,12 +399,12 @@ pub fn delete(
#[derive(Default, FromForm, Validate)]
#[validate(schema(
function = "passwords_match",
skip_on_field_errors = "false",
skip_on_field_errors = false,
message = "Passwords are not matching"
))]
pub struct NewUserForm {
#[validate(
length(min = "1", message = "Username can't be empty"),
length(min = 1, message = "Username can't be empty"),
custom(
function = "validate_username",
message = "User name is not allowed to contain any of < > & @ ' or \""
@ -413,9 +413,9 @@ pub struct NewUserForm {
pub username: String,
#[validate(email(message = "Invalid email"))]
pub email: String,
#[validate(length(min = "8", message = "Password should be at least 8 characters long"))]
#[validate(length(min = 8, message = "Password should be at least 8 characters long"))]
pub password: String,
#[validate(length(min = "8", message = "Password should be at least 8 characters long"))]
#[validate(length(min = 8, message = "Password should be at least 8 characters long"))]
pub password_confirmation: String,
}