diff --git a/src/main.rs b/src/main.rs index 854ba825..4d236661 100755 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/routes/comments.rs b/src/routes/comments.rs index c8618f99..5585afff 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -23,7 +23,7 @@ use plume_models::{ #[derive(Default, FromForm, Debug, Validate)] pub struct NewCommentForm { pub responding_to: Option, - #[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, } diff --git a/src/routes/email_signups.rs b/src/routes/email_signups.rs index 15a30db3..c874ec6c 100644 --- a/src/routes/email_signups.rs +++ b/src/routes/email_signups.rs @@ -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, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index ae7acd5c..cedaa900 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -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, } diff --git a/src/routes/session.rs b/src/routes/session.rs index 3264868b..1eab9693 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -37,9 +37,9 @@ pub fn new(m: Option, 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 { diff --git a/src/routes/user.rs b/src/routes/user.rs index 487d28d3..e7d66de1 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -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, }