#[non_exhaustive]pub enum Constraint {
Vocabulary {
terms: Vec<Term>,
closed: bool,
},
Other {
kind: String,
spec: Value,
},
}Expand description
This crate’s own constraint type: what a schema document’s constraint
loads as. One variant for the kind the format defines and one for every
kind it does not.
The seam this crate is built around is that a constraint is the embedder’s
type, and this does not close it: an embedder loads a Schema<Constraint>
and maps it into a schema over its own type with
Schema::map_constraints, reading the Other kinds
it knows and keeping the rest as its own unchecked variant. What this type
adds is that a reader with no embedder behind it — fig-schema check — can
still load the document and say honestly what it did and did not check.
#[non_exhaustive]: the format may define another kind, so a match
needs a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Vocabulary
A controlled vocabulary, checked by validate_enum.
Fields
Other
A constraint of a kind this crate does not define — prov’s
reference, or anything else an embedder reads. Validates every value
to Reject(Issue::unchecked(..)): the fail-closed half of the format’s
rule, spelled so that a reader which looks can tell unchecked from
wrong.
Implementations§
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§impl Debug for Constraint
impl Debug for Constraint
Source§impl Display for Constraint
impl Display for Constraint
Source§impl PartialEq for Constraint
impl PartialEq for Constraint
impl StructuralPartialEq for Constraint
Source§impl Validate for Constraint
impl Validate for Constraint
Source§fn validate(&self, value: &Value) -> Validation
fn validate(&self, value: &Value) -> Validation
value against this constraint.