pub struct StringValidator { /* private fields */ }Expand description
Validator for JSON strings.
Implementations§
Source§impl StringValidator
impl StringValidator
Sourcepub fn pattern(self, pattern: Regex) -> Self
pub fn pattern(self, pattern: Regex) -> Self
Set a pre-compiled regex pattern. The pattern is anchored so it must match the entire string (full-match semantics).
For a fallible builder, see StringValidator::try_pattern.
Sourcepub fn try_pattern(self, pattern: &str) -> Result<Self, Error>
pub fn try_pattern(self, pattern: &str) -> Result<Self, Error>
Compile a regex pattern. The pattern is anchored so it must match the entire string (full-match semantics). Returns an error if the pattern is invalid.
Source§impl StringValidator
impl StringValidator
Sourcepub fn sensitive(self, sensitive: bool) -> Self
pub fn sensitive(self, sensitive: bool) -> Self
Mark the field as sensitive (e.g. passwords, tokens).
When enabled, every error this validator produces redacts the
offending value: message interpolations render as *** and
ValidationError::value is None, so errors can be logged
safely. The flag is per-validator and is NOT inherited by
nested validators.
Trait Implementations§
Source§impl Default for StringValidator
impl Default for StringValidator
Source§impl Validator for StringValidator
impl Validator for StringValidator
Source§fn set_fail_fast(&mut self, fail_fast: bool)
fn set_fail_fast(&mut self, fail_fast: bool)
Set fail-fast mode for this validator and its children.
Source§fn validate(&self, value: &Value, field: &str) -> ValidationResult
fn validate(&self, value: &Value, field: &str) -> ValidationResult
Validate
value at the given field path.Source§fn is_required(&self) -> bool
fn is_required(&self) -> bool
Whether the field is required.
Source§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
Whether the field may be explicitly
null.Auto Trait Implementations§
impl !RefUnwindSafe for StringValidator
impl !UnwindSafe for StringValidator
impl Freeze for StringValidator
impl Send for StringValidator
impl Sync for StringValidator
impl Unpin for StringValidator
impl UnsafeUnpin for StringValidator
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