pub struct StringHandler;Expand description
String validation handler
Validates string fields according to the following rules:
- Must not be empty (required for all string fields)
- Must not exceed maximum length if specified
- Returns the original string if valid (no canonicalization needed)
Implementations§
Source§impl StringHandler
impl StringHandler
Sourcepub fn validate_and_canonicalize(
value: &str,
max_length: Option<usize>,
field_name: &str,
) -> Result<String>
pub fn validate_and_canonicalize( value: &str, max_length: Option<usize>, field_name: &str, ) -> Result<String>
Validate and canonicalize a string value
§Arguments
value- The string value to validatemax_length- Optional maximum length constraintfield_name- Name of the field (for error messages)
§Returns
Ok(String)- The validated string (unchanged)Err(anyhow::Error)- Validation failed with detailed error
Auto Trait Implementations§
impl Freeze for StringHandler
impl RefUnwindSafe for StringHandler
impl Send for StringHandler
impl Sync for StringHandler
impl Unpin for StringHandler
impl UnsafeUnpin for StringHandler
impl UnwindSafe for StringHandler
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