Struct fog_pack::validator::ArrayValidator [−][src]
Validator for arrays.
This validator type will only pass array values. Validation passes if:
- If the
inlist is not empty, the array must be among the arrays in the list. - The array must not be among the arrays in the
ninlist. - The arrays’s length is less than or equal to the value in
max_len. - The arrays’s length is greater than or equal to the value in
min_len. - If
uniqueis true, the array items are all unique. - For each validator in the
containslist, at least one item in the array passes. - Each item in the array is checked with a validator at the same index in the
prefixarray. All validators must pass. If there is no validator at the same index, the validator initemsmust pass. If a validator is not used, it passes automatially.
Defaults
Fields that aren’t specified for the validator use their defaults instead. The defaults for each field are:
- comment: “”
- contains: empty
- items: Validator::Any
- prefix: empty
- max_len: u32::MAX
- min_len: u32::MIN
- in_list: empty
- nin_list: empty
- unique: false
- query: false
- array: false
- contains_ok: false
- unique_ok: false
- size: false
Query Checking
Queries for arrays are only allowed to use non-default values for each field if the corresponding query permission is set in the schema’s validator:
- query:
inandninlists - array:
prefixanditems - contains_ok:
contains - unique_ok:
unique - size:
max_lenandmin_len
In addition, sub-validators in the query are matched against the schema’s sub-validators:
- Each validator in
containsis checked against all of the schema’sprefixvalidators, as well as itsitemsvalidator. - The
itemsvalidator is checked against the schema’s `items’ validator - The
prefixvalidators are checked against the schema’sprefixvalidators. Unmatched query validators are checked against the schema’sitemsvalidator.
Fields
comment: StringAn optional comment explaining the validator.
contains: Vec<Validator>For each validator in this array, at least one item in the array must pass the validator.
items: Box<Validator>A validator that each item in the array must pass, unless it is instead checked by
prefix.
prefix: Vec<Validator>An array of validators, which are matched up against the items in the array. Unmatched
validators automatically pass, while unmatched items are checked against the items
Validator.
max_len: u32The maximum allowed number of items in the array.
min_len: u32The minimum allowed number of items in the array.
in_list: Vec<Vec<Value>>A vector of specific allowed values, stored under the in field. If empty, this vector is not checked against.
nin_list: Vec<Vec<Value>>A vector of specific unallowed values, stored under the nin field.
unique: boolIf set, all items in the array must be unique.
query: boolIf true, queries against matching spots may have values in the in or nin lists.
array: boolIf true, queries against matching spots may use items and prefix.
contains_ok: boolIf true, queries against matching spots may use contains.
unique_ok: boolIf true, queries against matching spots may use unique.
size: boolIf true, queries against matching spots may use max_len and min_len.
Implementations
impl ArrayValidator[src]
pub fn new() -> Self[src]
Make a new validator with the default configuration.
pub fn comment(self, comment: impl Into<String>) -> Self[src]
Set a comment for the validator.
pub fn contains_add(self, validator: Validator) -> Self[src]
Extend the contains list with another validator
pub fn items(self, items: Validator) -> Self[src]
Set the items validator.
pub fn prefix_add(self, prefix: Validator) -> Self[src]
Extend the prefix list with another validator
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.
pub fn in_add(self, add: impl Into<Vec<Value>>) -> Self[src]
Add a value to the in list.
pub fn nin_add(self, add: impl Into<Vec<Value>>) -> Self[src]
Add a value to the nin list.
pub fn unique(self, unique: bool) -> Self[src]
Set whether the items in the array must be unique.
pub fn query(self, query: bool) -> Self[src]
Set whether or not queries can use the in and nin lists.
pub fn array(self, array: bool) -> Self[src]
Set whether or not queries can use the items and prefix values.
pub fn contains_ok(self, contains_ok: bool) -> Self[src]
Set whether or not queries can use the contains value.
pub fn unique_ok(self, unique_ok: bool) -> Self[src]
Set whether or not queries can use the unique setting.
pub fn size(self, size: bool) -> Self[src]
Set whether or not queries can use the max_len and min_len values.
pub fn build(self) -> Validator[src]
Build this into a Validator enum.
Trait Implementations
impl Clone for ArrayValidator[src]
fn clone(&self) -> ArrayValidator[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for ArrayValidator[src]
impl Default for ArrayValidator[src]
impl<'de> Deserialize<'de> for ArrayValidator where
ArrayValidator: Default, [src]
ArrayValidator: Default,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<ArrayValidator> for ArrayValidator[src]
fn eq(&self, other: &ArrayValidator) -> bool[src]
fn ne(&self, other: &ArrayValidator) -> bool[src]
impl Serialize for ArrayValidator[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for ArrayValidator[src]
Auto Trait Implementations
impl RefUnwindSafe for ArrayValidator
impl Send for ArrayValidator
impl Sync for ArrayValidator
impl Unpin for ArrayValidator
impl UnwindSafe for ArrayValidator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,