Skip to main content

ValidationVocabulary

Struct ValidationVocabulary 

Source
pub struct ValidationVocabulary {
Show 20 fields pub type_: Option<TypeValue>, pub enum_: Option<Vec<Value>>, pub const_: Option<Value>, pub minimum: Option<Number>, pub maximum: Option<Number>, pub exclusive_minimum: Option<Number>, pub exclusive_maximum: Option<Number>, pub multiple_of: Option<Number>, pub min_length: Option<u64>, pub max_length: Option<u64>, pub pattern: Option<String>, pub min_items: Option<u64>, pub max_items: Option<u64>, pub unique_items: bool, pub min_contains: Option<u64>, pub max_contains: Option<u64>, pub required: Option<Vec<String>>, pub min_properties: Option<u64>, pub max_properties: Option<u64>, pub dependent_required: Option<IndexMap<String, Vec<String>>>,
}
Expand description

Validation vocabulary — type checks and numeric, string, array, and object constraints.

See JSON Schema Validation §6.

Fields§

§type_: Option<TypeValue>

The type keyword — instance type constraint.

The value of this keyword MUST be either a string or an array. If it is an array, elements of the array MUST be strings and MUST be unique.

String values MUST be one of the six primitive types ("null", "boolean", "object", "array", "number", or "string"), or "integer" which matches any number with a zero fractional part.

If the value of "type" is a string, then an instance validates successfully if its type matches the type represented by the value of the string. If the value of "type" is an array, then an instance validates successfully if its type matches any of the types indicated by the strings in the array.

See JSON Schema Validation §6.1.1.

§enum_: Option<Vec<Value>>

The enum keyword — enumerated values constraint.

The value of this keyword MUST be an array. This array SHOULD have at least one element. Elements in the array SHOULD be unique.

An instance validates successfully against this keyword if its value is equal to one of the elements in this keyword’s array value.

Elements in the array might be of any type, including null.

See JSON Schema Validation §6.1.2.

§const_: Option<Value>

The const keyword — constant value constraint.

The value of this keyword MAY be of any type, including null.

Use of this keyword is functionally equivalent to an "enum" (Section 6.1.2) with a single value.

An instance validates successfully against this keyword if its value is equal to the value of the keyword.

See JSON Schema Validation §6.1.3.

§minimum: Option<Number>

The minimum keyword — inclusive lower bound.

The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.

If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".

See JSON Schema Validation §6.2.4.

§maximum: Option<Number>

The maximum keyword — inclusive upper bound.

The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.

If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".

See JSON Schema Validation §6.2.2.

§exclusive_minimum: Option<Number>

The exclusiveMinimum keyword — exclusive lower bound.

The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower limit for a numeric instance.

If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".

See JSON Schema Validation §6.2.5.

§exclusive_maximum: Option<Number>

The exclusiveMaximum keyword — exclusive upper bound.

The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper limit for a numeric instance.

If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".

See JSON Schema Validation §6.2.3.

§multiple_of: Option<Number>

The multipleOf keyword — divisibility constraint.

The value of "multipleOf" MUST be a number, strictly greater than 0.

A numeric instance is valid only if division by this keyword’s value results in an integer.

See JSON Schema Validation §6.2.1.

§min_length: Option<u64>

The minLength keyword — minimum string length.

The value of this keyword MUST be a non-negative integer.

A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.

The length of a string instance is defined as the number of its characters as defined by RFC 8259.

Omitting this keyword has the same behavior as a value of 0.

See JSON Schema Validation §6.3.2.

§max_length: Option<u64>

The maxLength keyword — maximum string length.

The value of this keyword MUST be a non-negative integer.

A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.

The length of a string instance is defined as the number of its characters as defined by RFC 8259.

See JSON Schema Validation §6.3.1.

§pattern: Option<String>

The pattern keyword — regex constraint.

The value of this keyword MUST be a string. This string SHOULD be a valid regular expression, according to the ECMA-262 regular expression dialect.

A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.

See JSON Schema Validation §6.3.3.

§min_items: Option<u64>

The minItems keyword — minimum array length.

The value of this keyword MUST be a non-negative integer.

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.

Omitting this keyword has the same behavior as a value of 0.

See JSON Schema Validation §6.4.2.

§max_items: Option<u64>

The maxItems keyword — maximum array length.

The value of this keyword MUST be a non-negative integer.

An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.

See JSON Schema Validation §6.4.1.

§unique_items: bool

The uniqueItems keyword — array element uniqueness.

The value of this keyword MUST be a boolean.

If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.

Omitting this keyword has the same behavior as a value of false.

See JSON Schema Validation §6.4.3.

§min_contains: Option<u64>

The minContains keyword — minimum contains matches.

The value of this keyword MUST be a non-negative integer.

If "contains" is not present within the same schema object, then this keyword has no effect.

An instance array is valid against "minContains" in two ways, depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is greater than or equal to the "minContains" value. The second way is if the annotation result is a boolean true and the instance array length is greater than or equal to the "minContains" value.

A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 causes "minContains" and "contains" to always pass validation (but validation can still fail against a "maxContains" keyword).

Omitting this keyword has the same behavior as a value of 1.

See JSON Schema Validation §6.4.5.

§max_contains: Option<u64>

The maxContains keyword — maximum contains matches.

The value of this keyword MUST be a non-negative integer.

If "contains" is not present within the same schema object, then this keyword has no effect.

An instance array is valid against "maxContains" in two ways, depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is less than or equal to the "maxContains" value. The second way is if the annotation result is a boolean true and the instance array length is less than or equal to the "maxContains" value.

See JSON Schema Validation §6.4.4.

§required: Option<Vec<String>>

The required keyword — required property names.

The value of this keyword MUST be an array. Elements of this array, if any, MUST be strings, and MUST be unique.

An object instance is valid against this keyword if every item in the array is the name of a property in the instance.

Omitting this keyword has the same behavior as an empty array.

See JSON Schema Validation §6.5.3.

§min_properties: Option<u64>

The minProperties keyword — minimum property count.

The value of this keyword MUST be a non-negative integer.

An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

Omitting this keyword has the same behavior as a value of 0.

See JSON Schema Validation §6.5.2.

§max_properties: Option<u64>

The maxProperties keyword — maximum property count.

The value of this keyword MUST be a non-negative integer.

An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

See JSON Schema Validation §6.5.1.

§dependent_required: Option<IndexMap<String, Vec<String>>>

The dependentRequired keyword — conditional required properties.

The value of this keyword MUST be an object. Properties in this object, if any, MUST be arrays. Elements in each array, if any, MUST be strings, and MUST be unique.

This keyword specifies properties that are required if a specific other property is present. Their requirement is dependent on the presence of the other property.

Validation succeeds if, for each name that appears in both the instance and as a name within this keyword’s value, every item in the corresponding array is also the name of a property in the instance.

Omitting this keyword has the same behavior as an empty object.

See JSON Schema Validation §6.5.4.

Trait Implementations§

Source§

impl Clone for ValidationVocabulary

Source§

fn clone(&self) -> ValidationVocabulary

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidationVocabulary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValidationVocabulary

Source§

fn default() -> ValidationVocabulary

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

impl<'de> Deserialize<'de> for ValidationVocabulary

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for ValidationVocabulary

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for ValidationVocabulary

Source§

fn eq(&self, other: &ValidationVocabulary) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ValidationVocabulary

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ValidationVocabulary

Source§

impl StructuralPartialEq for ValidationVocabulary

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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