Skip to content

Commit

Permalink
Merge branch 'main' of github.com:yassun4dev/serde_valid into v0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yassun7010 committed Jan 13, 2024
2 parents 7f73ae7 + b415a38 commit 0313be7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn get_enumerate(meta_list: &syn::MetaList) -> Result<Lits, crate::Errors> {
crate::types::NestedMeta::Lit(lit) => enumerate.push(lit.clone()),
crate::types::NestedMeta::Meta(meta) => errors.push(crate::Error::literal_only(meta)),
crate::types::NestedMeta::Closure(closure) => {
errors.push(crate::Error::closure_not_support(closure))
errors.push(crate::Error::closure_not_supported(closure))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions serde_valid_derive/src/attribute/field_validate/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn extract_field_validator(
syn::Meta::List(list) => inner_extract_field_validator(field, attribute, list, rename_map),
syn::Meta::Path(_) => extract_generic_validate_validator(field, rename_map),
syn::Meta::NameValue(name_value) => {
Err(vec![crate::Error::validate_meta_name_value_not_support(
Err(vec![crate::Error::validate_meta_name_value_not_supported(
name_value,
)])
}
Expand Down Expand Up @@ -57,9 +57,9 @@ fn inner_extract_field_validator(
2 => match extract_custom_message_format(&nested[1]) {
Ok(custom_message) => {
if nested[0].path().is_ident("custom") {
errors.push(crate::Error::validate_custom_not_support_custom_message(
&nested[1],
));
errors.push(
crate::Error::validate_custom_does_not_support_custom_message(&nested[1]),
);
None
} else {
Some(custom_message)
Expand Down
8 changes: 4 additions & 4 deletions serde_valid_derive/src/attribute/struct_validate/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn extract_struct_validator(attribute: &syn::Attribute) -> Result<Validator,
syn::Meta::Path(_) => Ok(quote!()),
syn::Meta::List(list) => inner_extract_struct_validator(attribute, list),
syn::Meta::NameValue(name_value) => {
Err(vec![crate::Error::validate_meta_name_value_not_support(
Err(vec![crate::Error::validate_meta_name_value_not_supported(
name_value,
)])
}
Expand Down Expand Up @@ -52,9 +52,9 @@ fn inner_extract_struct_validator(
2 => match extract_custom_message_format(&nested[1]) {
Ok(custom_message) => {
if nested[0].path().is_ident("custom") {
errors.push(crate::Error::validate_custom_not_support_custom_message(
&nested[1],
));
errors.push(
crate::Error::validate_custom_does_not_support_custom_message(&nested[1]),
);
None
} else {
Some(custom_message)
Expand Down
4 changes: 2 additions & 2 deletions serde_valid_derive/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub fn expand_derive(input: &syn::DeriveInput) -> Result<TokenStream, crate::Err
syn::Data::Struct(syn::DataStruct { ref fields, .. }) => match fields {
syn::Fields::Named(fields) => expand_named_struct_derive(input, fields),
syn::Fields::Unnamed(fields) => expand_unnamed_struct_derive(input, fields),
syn::Fields::Unit => Err(vec![crate::Error::unit_struct_not_support(input)]),
syn::Fields::Unit => Err(vec![crate::Error::unit_struct_not_supported(input)]),
},
syn::Data::Enum(syn::DataEnum { variants, .. }) => {
expand_enum_validate_derive(input, variants)
}
syn::Data::Union(_) => Err(vec![crate::Error::union_not_support(input)]),
syn::Data::Union(_) => Err(vec![crate::Error::union_not_supported(input)]),
}
}
14 changes: 7 additions & 7 deletions serde_valid_derive/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ impl Error {
Error::new(span, message)
}

pub fn unit_struct_not_support(input: &syn::DeriveInput) -> Self {
pub fn unit_struct_not_supported(input: &syn::DeriveInput) -> Self {
Self::new(
input.span(),
"#[derive(Validate)] does not support Unit Struct.",
)
}

pub fn union_not_support(input: &syn::DeriveInput) -> Self {
pub fn union_not_supported(input: &syn::DeriveInput) -> Self {
Self::new(input.span(), "#[derive(Validate)] does not support Union.")
}

Expand Down Expand Up @@ -225,8 +225,8 @@ impl Error {
)
}

pub fn validate_meta_name_value_not_support(name_value: &syn::MetaNameValue) -> Self {
Self::new(name_value.span(), "#[validate = ???] does not support.")
pub fn validate_meta_name_value_not_supported(name_value: &syn::MetaNameValue) -> Self {
Self::new(name_value.span(), "#[validate = ???] not supported.")
}

pub fn meta_path_validation_need_value(path: &syn::Path, validation_type: &str) -> Self {
Expand Down Expand Up @@ -457,10 +457,10 @@ impl Error {
Self::new(lit.span(), "Allow str literal only.")
}

pub fn closure_not_support(closure: &syn::ExprClosure) -> Self {
pub fn closure_not_supported(closure: &syn::ExprClosure) -> Self {
Self::new(
closure.or1_token.span(),
format!("Closure not support. {}", closure.to_token_stream()),
format!("Closure not supported. {}", closure.to_token_stream()),
)
}

Expand All @@ -472,7 +472,7 @@ impl Error {
self.0.to_compile_error()
}

pub fn validate_custom_not_support_custom_message(meta: &syn::Meta) -> Self {
pub fn validate_custom_does_not_support_custom_message(meta: &syn::Meta) -> Self {
Self::new(
meta.span(),
"#[validate(custon(...), ???)] does not support custom error message.",
Expand Down

0 comments on commit 0313be7

Please sign in to comment.