pub trait Validate<T: ?Sized>:
'static
+ Send
+ Sync {
// Required methods
fn describe(&self, formatter: &mut Formatter<'_>) -> Result;
fn validate(&self, target: &T) -> Result<(), ErrorWithOrigin>;
}Expand description
Generic post-validation for a configuration parameter or a config.
§Implementations
Validations are implemented for the following types:
NotEmpty. Validates that a string or a collection, such asVec, is not empty.Range,RangeInclusiveetc. Validates whether the type is within the provided bounds.
Required Methods§
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: ?Sized, V: Validate<T> + ?Sized> Validate<T> for &'static V
Delegates via a reference. Useful for defining validation constants as &'static dyn Validate<_>.
impl<T: ?Sized, V: Validate<T> + ?Sized> Validate<T> for &'static V
Delegates via a reference. Useful for defining validation constants as &'static dyn Validate<_>.
Source§impl<T> Validate<T> for RangeInclusive<T>
impl<T> Validate<T> for RangeInclusive<T>
Source§impl<T> Validate<T> for RangeToInclusive<T>
impl<T> Validate<T> for RangeToInclusive<T>
Implementors§
impl Validate<String> for NotEmpty
impl<K, S> Validate<HashSet<K, S>> for NotEmpty
impl<K, V, S> Validate<HashMap<K, V, S>> for NotEmpty
impl<K, V> Validate<BTreeMap<K, V>> for NotEmpty
impl<K> Validate<BTreeSet<K>> for NotEmpty
impl<T> Validate<String> for LazyRegex<T>
Validates that the string matches the provided regex.
Don’t forget to surround the regex with ^$ if you want to match it completely.