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,
}
Expand description

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

Make a new validator with the default configuration.

Set the regular expression to check against.

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

Set the maximum number of allowed bytes.

Set the minimum number of allowed bytes.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.