pub struct EnumHandler;Implementations§
Source§impl EnumHandler
impl EnumHandler
Sourcepub fn validate_and_canonicalize(
value: &str,
allowed_values: &[String],
field_name: &str,
) -> Result<String>
pub fn validate_and_canonicalize( value: &str, allowed_values: &[String], field_name: &str, ) -> Result<String>
Validate and canonicalize an enumeration value
This method performs case-insensitive validation against the allowed values list and canonicalizes the result to lowercase for consistency.
§Validation Process
- Convert input to lowercase for comparison
- Check if lowercase value exists in allowed values (case-insensitive)
- Return the lowercase canonical form if valid
- Provide detailed error with all allowed values if invalid
§Arguments
value- The input value to validateallowed_values- List of allowed values (case-insensitive matching)field_name- Name of the field being validated (for error messages)
§Returns
Ok(String)- The value in canonical lowercase formErr(anyhow::Error)- Value not in allowed list with helpful error
Auto Trait Implementations§
impl Freeze for EnumHandler
impl RefUnwindSafe for EnumHandler
impl Send for EnumHandler
impl Sync for EnumHandler
impl Unpin for EnumHandler
impl UnsafeUnpin for EnumHandler
impl UnwindSafe for EnumHandler
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