upgrade validator: it now uses types! in macros!!
This commit is contained in:
parent
0726375859
commit
07036b5fad
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -1536,9 +1536,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "if_chain"
|
name = "if_chain"
|
||||||
version = "0.1.3"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec"
|
checksum = "c3360c7b59e5ffa2653671fb74b4741a5d343c03f331c0a4aeda42b5c2b0ec7d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
@ -3981,31 +3981,31 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "validator"
|
name = "validator"
|
||||||
version = "0.8.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "236a5eda3df2c877872e98dbc55d497d943792e6405d8fc65bd4f8a5e3b53c99"
|
checksum = "7ab5990ba09102e1ddc954d294f09b9ea00fc7831a5813bbe84bfdbcae44051e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"idna 0.1.5",
|
"idna 0.2.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"url 1.7.2",
|
"url 2.1.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "validator_derive"
|
name = "validator_derive"
|
||||||
version = "0.8.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d360d6f5754972c0c1da14fb3d5580daa31aee566e1e45e2f8d3bf5950ecd3e9"
|
checksum = "e668e9cd05c5009b833833aa1147e5727b5396ea401f22dd1167618eed4a10c9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"if_chain",
|
"if_chain",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"proc-macro2 0.4.30",
|
"proc-macro2 1.0.17",
|
||||||
"quote 0.6.13",
|
"quote 1.0.6",
|
||||||
"regex",
|
"regex",
|
||||||
"syn 0.15.44",
|
"syn 1.0.23",
|
||||||
"validator",
|
"validator",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ serde_qs = "0.5"
|
|||||||
shrinkwraprs = "0.2.1"
|
shrinkwraprs = "0.2.1"
|
||||||
syntect = "3.3"
|
syntect = "3.3"
|
||||||
tokio = "0.2"
|
tokio = "0.2"
|
||||||
validator = "0.8"
|
validator = "0.10"
|
||||||
validator_derive = "0.8"
|
validator_derive = "0.10"
|
||||||
webfinger = { git = "https://github.com/Plume-org/webfinger", rev = "4e8f12810c4a7ba7a07bbcb722cd265fdff512b6", features = ["async"] }
|
webfinger = { git = "https://github.com/Plume-org/webfinger", rev = "4e8f12810c4a7ba7a07bbcb722cd265fdff512b6", features = ["async"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
@ -9,6 +9,7 @@ extern crate rocket;
|
|||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate validator_derive;
|
extern crate validator_derive;
|
||||||
|
extern crate validator;
|
||||||
|
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use diesel::r2d2::ConnectionManager;
|
use diesel::r2d2::ConnectionManager;
|
||||||
|
@ -22,7 +22,7 @@ use plume_models::{
|
|||||||
#[derive(Default, FromForm, Debug, Validate)]
|
#[derive(Default, FromForm, Debug, Validate)]
|
||||||
pub struct NewCommentForm {
|
pub struct NewCommentForm {
|
||||||
pub responding_to: Option<i32>,
|
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 content: String,
|
||||||
pub warning: String,
|
pub warning: String,
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,12 @@ pub fn admin_mod(_mod: Moderator, rockets: PlumeRocket) -> Ructe {
|
|||||||
|
|
||||||
#[derive(Clone, FromForm, Validate)]
|
#[derive(Clone, FromForm, Validate)]
|
||||||
pub struct InstanceSettingsForm {
|
pub struct InstanceSettingsForm {
|
||||||
#[validate(length(min = "1"))]
|
#[validate(length(min = 1))]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub open_registrations: bool,
|
pub open_registrations: bool,
|
||||||
pub short_description: SafeString,
|
pub short_description: SafeString,
|
||||||
pub long_description: SafeString,
|
pub long_description: SafeString,
|
||||||
#[validate(length(min = "1"))]
|
#[validate(length(min = 1))]
|
||||||
pub default_license: String,
|
pub default_license: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ pub fn new(m: Option<String>, rockets: PlumeRocket) -> Ructe {
|
|||||||
|
|
||||||
#[derive(Default, FromForm, Validate)]
|
#[derive(Default, FromForm, Validate)]
|
||||||
pub struct LoginForm {
|
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,
|
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,
|
pub password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ pub fn password_reset_form(token: String, rockets: PlumeRocket) -> Result<Ructe,
|
|||||||
#[derive(FromForm, Default, Validate)]
|
#[derive(FromForm, Default, Validate)]
|
||||||
#[validate(schema(
|
#[validate(schema(
|
||||||
function = "passwords_match",
|
function = "passwords_match",
|
||||||
skip_on_field_errors = "false",
|
skip_on_field_errors = false,
|
||||||
message = "Passwords are not matching"
|
message = "Passwords are not matching"
|
||||||
))]
|
))]
|
||||||
pub struct NewPasswordForm {
|
pub struct NewPasswordForm {
|
||||||
|
@ -455,12 +455,12 @@ pub async fn delete(
|
|||||||
#[derive(Default, FromForm, Validate)]
|
#[derive(Default, FromForm, Validate)]
|
||||||
#[validate(schema(
|
#[validate(schema(
|
||||||
function = "passwords_match",
|
function = "passwords_match",
|
||||||
skip_on_field_errors = "false",
|
skip_on_field_errors = false,
|
||||||
message = "Passwords are not matching"
|
message = "Passwords are not matching"
|
||||||
))]
|
))]
|
||||||
pub struct NewUserForm {
|
pub struct NewUserForm {
|
||||||
#[validate(
|
#[validate(
|
||||||
length(min = "1", message = "Username can't be empty"),
|
length(min = 1, message = "Username can't be empty"),
|
||||||
custom(
|
custom(
|
||||||
function = "validate_username",
|
function = "validate_username",
|
||||||
message = "User name is not allowed to contain any of < > & @ ' or \""
|
message = "User name is not allowed to contain any of < > & @ ' or \""
|
||||||
@ -469,9 +469,9 @@ pub struct NewUserForm {
|
|||||||
pub username: String,
|
pub username: String,
|
||||||
#[validate(email(message = "Invalid email"))]
|
#[validate(email(message = "Invalid email"))]
|
||||||
pub email: String,
|
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,
|
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 password_confirmation: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user