pub struct PatternRule { /* private fields */ }Expand description
Validates a string against a compiled regular expression (full-string match).
The pattern is anchored with ^...$ so that it must match the entire value,
mirroring XSD <xs:pattern> behaviour.
§Examples
use mx20022_validate::rules::pattern::PatternRule;
use mx20022_validate::rules::Rule;
let rule = PatternRule::new("COUNTRY_CODE", "[A-Z]{2}").unwrap();
assert!(rule.validate("GB", "/path").is_empty());
assert!(!rule.validate("gb", "/path").is_empty());
assert!(!rule.validate("GBR", "/path").is_empty());Implementations§
Source§impl PatternRule
impl PatternRule
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PatternRule
impl RefUnwindSafe for PatternRule
impl Send for PatternRule
impl Sync for PatternRule
impl Unpin for PatternRule
impl UnsafeUnpin for PatternRule
impl UnwindSafe for PatternRule
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