Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export regex. #87

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading