Skip to main content

Constraints

Struct Constraints 

Source
pub struct Constraints {
Show 16 fields pub pattern: Option<String>, pub min_length: Option<usize>, pub max_length: Option<usize>, pub minimum: Option<Bound>, pub maximum: Option<Bound>, pub exclusive_minimum: bool, pub exclusive_maximum: bool, pub folded_minimum: bool, pub folded_maximum: bool, pub multiple_of: Option<Bound>, pub min_items: Option<usize>, pub max_items: Option<usize>, pub unique_items: bool, pub min_properties: Option<usize>, pub max_properties: Option<usize>, pub checked_as: Option<RustType>,
}
Expand description

The validation keywords a schema declares.

A field with no keyword carries None, so the common schema costs nothing.

Fields§

§pattern: Option<String>

pattern: the value must match this regular expression.

§min_length: Option<usize>

minLength, counted in characters, as JSON Schema counts them.

§max_length: Option<usize>

maxLength, counted in characters.

§minimum: Option<Bound>

minimum.

§maximum: Option<Bound>

maximum.

§exclusive_minimum: bool

exclusiveMinimum: makes minimum a strict bound.

§exclusive_maximum: bool

exclusiveMaximum: makes maximum a strict bound.

§folded_minimum: bool

Whether minimum moved to absorb an exclusiveMinimum.

The bound then holds a number the document does not write, and a message about it must name the number the author wrote instead.

§folded_maximum: bool

Whether maximum moved to absorb an exclusiveMaximum.

§multiple_of: Option<Bound>

multipleOf.

§min_items: Option<usize>

minItems.

§max_items: Option<usize>

maxItems.

§unique_items: bool

uniqueItems.

§min_properties: Option<usize>

minProperties.

§max_properties: Option<usize>

maxProperties.

§checked_as: Option<RustType>

The type the checks run against, when the field names an alias.

A $ref to a constrained scalar gives the field a named type, and the name alone does not say which check applies. Lowering resolves the ref and records the type behind the name here.

Implementations§

Source§

impl Constraints

Source

pub fn is_empty(&self) -> bool

Whether the schema declares no keyword at all.

Trait Implementations§

Source§

impl Clone for Constraints

Source§

fn clone(&self) -> Constraints

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Constraints

Source§

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

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

impl Default for Constraints

Source§

fn default() -> Constraints

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

impl PartialEq for Constraints

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Constraints

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> 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.