pub struct PatternValidator { /* private fields */ }Expand description
Pattern validator using regular expressions.
Implementations§
Source§impl PatternValidator
impl PatternValidator
Sourcepub fn new_default_message(pattern: impl Into<String>) -> Result<Self>
pub fn new_default_message(pattern: impl Into<String>) -> Result<Self>
Create a new pattern validator with default message.
§Errors
Returns FraiseQLError::Validation if the regex pattern is invalid.
Sourcepub fn from_compiled(regex: Regex, message: impl Into<String>) -> Self
pub fn from_compiled(regex: Regex, message: impl Into<String>) -> Self
Build a pattern validator from an already-compiled regex.
Used by create_validator_from_rule when the ValidationRule::Pattern
variant has already compiled the pattern at construction time, so we
avoid a redundant Regex::new call here.
Sourcepub fn validate_pattern(&self, value: &str) -> bool
pub fn validate_pattern(&self, value: &str) -> bool
Validate that a value matches the pattern.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PatternValidator
impl RefUnwindSafe for PatternValidator
impl Send for PatternValidator
impl Sync for PatternValidator
impl Unpin for PatternValidator
impl UnsafeUnpin for PatternValidator
impl UnwindSafe for PatternValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more