pub struct StringSchema { /* private fields */ }Expand description
Schema representing string constraints and mapping metadata.
Implementations§
Source§impl StringSchema
impl StringSchema
Sourcepub fn min_length(self, n: usize) -> Self
pub fn min_length(self, n: usize) -> Self
Constrains the string to have a minimum character count of $N$.
Sourcepub fn max_length(self, n: usize) -> Self
pub fn max_length(self, n: usize) -> Self
Constrains the string to have a maximum character count of $M$.
Sourcepub fn alphanumeric(self) -> Self
pub fn alphanumeric(self) -> Self
Constrains the string to contain only alphanumeric characters.
Sourcepub fn regex(self, pattern: &str) -> Self
pub fn regex(self, pattern: &str) -> Self
Matches the string value against a custom Rust regular expression pattern.
Sourcepub fn default(self, val: &str) -> Self
pub fn default(self, val: &str) -> Self
Configures a fallback default value used when this field is missing.
Sourcepub fn alias(self, name: &str) -> Self
pub fn alias(self, name: &str) -> Self
Registers a field key rename mapping for parsing input payloads.
Trait Implementations§
Source§impl Default for StringSchema
impl Default for StringSchema
Source§fn default() -> StringSchema
fn default() -> StringSchema
Returns the “default value” for a type. Read more
Source§impl SchemaValidator for StringSchema
impl SchemaValidator for StringSchema
Source§fn is_required(&self) -> bool
fn is_required(&self) -> bool
Returns
true if the field must be supplied and lacks a default value.Source§fn default_value(&self) -> Option<Value>
fn default_value(&self) -> Option<Value>
Yields the fallback
Value if this optional/default field is omitted.Source§fn schema_type(&self) -> &'static str
fn schema_type(&self) -> &'static str
Static string representing the readable type name.
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