pub struct StringSchema { /* private fields */ }Implementations§
Source§impl StringSchema
impl StringSchema
pub fn new() -> Self
pub fn min(self, min: usize) -> Self
pub fn max(self, max: usize) -> Self
pub fn length(self, len: usize) -> Self
pub fn starts_with(self, val: &str) -> Self
pub fn ends_with(self, val: &str) -> Self
pub fn includes(self, val: &str) -> Self
Sourcepub fn regex(self, pattern: &str) -> Self
pub fn regex(self, pattern: &str) -> Self
Sets a regex pattern for validation.
§Panics
Panics if the pattern is not a valid regex. Use try_regex() for fallible version.
Sourcepub fn try_regex(self, pattern: &str) -> Result<Self, Error>
pub fn try_regex(self, pattern: &str) -> Result<Self, Error>
Sets a regex pattern for validation, returning an error if the pattern is invalid.
pub fn email(self) -> Self
pub fn url(self) -> Self
Trait Implementations§
Source§impl Clone for StringSchema
impl Clone for StringSchema
Source§fn clone(&self) -> StringSchema
fn clone(&self) -> StringSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringSchema
impl Debug for StringSchema
Source§impl Default for StringSchema
impl Default for StringSchema
Source§impl Schema<String> for StringSchema
impl Schema<String> for StringSchema
Source§fn validate(&self, value: &Value) -> ValidateResult<String>
fn validate(&self, value: &Value) -> ValidateResult<String>
Validates the value against this schema and returns the validated result.
Source§fn parse(&self, value: &Value) -> T
fn parse(&self, value: &Value) -> T
Validates and returns the result, panicking on validation failure. Read more
Source§fn safe_parse(&self, value: &Value) -> ValidateResult<T>
fn safe_parse(&self, value: &Value) -> ValidateResult<T>
Validates the value and returns a Result. This is the recommended method for handling
validation in production code.
fn optional(self) -> OptionalSchema<Self, T>where
Self: Sized,
fn array(self) -> ArraySchema<Self, T>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for StringSchema
impl RefUnwindSafe for StringSchema
impl Send for StringSchema
impl Sync for StringSchema
impl Unpin for StringSchema
impl UnsafeUnpin for StringSchema
impl UnwindSafe for StringSchema
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