pub trait Validator {
    type Error;

    // Required method
    fn validate(raw: &str) -> Result<(), Self::Error>;
}
Expand description

A validator that can verify a given input is valid given certain preconditions

If the type can be normalized, this implementation should also validate that the value is already in normalized form.

Required Associated Types§

source

type Error

The error produced when the string is invalid

TryFrom<String>::Error for the wrapped type must be convertable into this error type. In most cases, this conversion is infallible, and so the error type needs to implement From<Infallible>. See the from_infallible!() helper macro to quickly implement this for your error type.

Required Methods§

source

fn validate(raw: &str) -> Result<(), Self::Error>

Validates a string according to a predetermined set of rules

Errors

Returns an error if the string is invalid or not in normalized form.

Implementors§