Skip to content

Commit

Permalink
Merge pull request #87 from yassun7010/export_regex
Browse files Browse the repository at this point in the history
feat: export regex.
  • Loading branch information
yassun7010 authored Dec 27, 2024
2 parents ef3abf1 + 6cbdf1b commit 267ca54
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions serde_valid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ pub mod export {
#[cfg(feature = "fluent")]
pub use fluent;
pub use once_cell;
pub use regex;
}

pub trait Validate {
Expand Down
2 changes: 1 addition & 1 deletion serde_valid/tests/nested_struct_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn nested_validate_err_message() {
};

assert_eq!(
serde_json::to_value(&s.validate().unwrap_err()).unwrap(),
serde_json::to_value(s.validate().unwrap_err()).unwrap(),
json!({
"errors": [],
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion serde_valid_derive/src/attribute/common/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub enum LitNumeric<'a> {
Float(&'a syn::LitFloat),
}

impl<'a> ToTokens for LitNumeric<'a> {
impl ToTokens for LitNumeric<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
LitNumeric::Int(lin) => lin.to_tokens(tokens),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fn inner_extract_string_pattern_validator(
);

Ok(quote!(
static #pattern_ident : ::serde_valid::export::once_cell::sync::OnceCell<::regex::Regex> = ::serde_valid::export::once_cell::sync::OnceCell::new();
let __pattern = #pattern_ident.get_or_init(|| ::regex::Regex::new(#pattern).unwrap());
static #pattern_ident : ::serde_valid::export::once_cell::sync::OnceCell<::serde_valid::export::regex::Regex> = ::serde_valid::export::once_cell::sync::OnceCell::new();
let __pattern = #pattern_ident.get_or_init(|| ::serde_valid::export::regex::Regex::new(#pattern).unwrap());
if let Err(__composited_error_params) = ::serde_valid::validation::ValidateCompositedPattern::validate_composited_pattern(
#field_ident,
__pattern,
Expand Down
2 changes: 1 addition & 1 deletion serde_valid_derive/src/types/field/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> NamedField<'a> {
}
}

impl<'a> Field for NamedField<'a> {
impl Field for NamedField<'_> {
fn name(&self) -> &String {
&self.name
}
Expand Down
2 changes: 1 addition & 1 deletion serde_valid_derive/src/types/field/unnamed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'a> UnnamedField<'a> {
}
}

impl<'a> Field for UnnamedField<'a> {
impl Field for UnnamedField<'_> {
fn name(&self) -> &String {
&self.name
}
Expand Down

0 comments on commit 267ca54

Please sign in to comment.