Struct fog_pack::validator::KeyValidator[][src]

pub struct KeyValidator {
    pub matches: Option<Box<Regex>>,
    pub normalize: Normalize,
    pub max_len: u32,
    pub min_len: u32,
}

Special validator for the keys in a Map. Used by MapValidator.

This validator type will only pass UTF-8 strings as map keys. Validation passes if:

  • The number of bytes in the string is less than or equal to max_len.
  • The number of bytes in the string is greater than or equal to min_len.
  • If a regular expression is present in matches, the possibly-normalized string must match against the expression.

The normalize field sets any Unicode normalization that should be applied to the string. See StrValidator’s documentation for details.

Defaults

Fields that aren’t specified for the validator use their defaults instead. The defaults for each field are:

  • comment: “”
  • matches: None
  • normalize: Normalize::None
  • max_len: u32::MAX
  • min_len: 0

Fields

matches: Option<Box<Regex>>

A regular expression that the value must match against.

normalize: Normalize

The Unicode normalization setting.

max_len: u32

The maximum allowed number of bytes in the string value.

min_len: u32

The minimum allowed number of bytes in the string value.

Implementations

impl KeyValidator[src]

pub fn new() -> Self[src]

Make a new validator with the default configuration.

pub fn matches(self, matches: Regex) -> Self[src]

Set the regular expression to check against.

pub fn normalize(self, normalize: Normalize) -> Self[src]

Set the unicode normalization form to use for in, nin, and matches checks.

pub fn max_len(self, max_len: u32) -> Self[src]

Set the maximum number of allowed bytes.

pub fn min_len(self, min_len: u32) -> Self[src]

Set the minimum number of allowed bytes.

Trait Implementations

impl Clone for KeyValidator[src]

impl Debug for KeyValidator[src]

impl Default for KeyValidator[src]

impl<'de> Deserialize<'de> for KeyValidator where
    KeyValidator: Default
[src]

impl PartialEq<KeyValidator> for KeyValidator[src]

impl Serialize for KeyValidator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,