pub enum Schema {
String {
min: Option<f64>,
max: Option<f64>,
pattern: Option<Regex>,
},
Format {
format: StringFormat,
min: Option<f64>,
max: Option<f64>,
pattern: Option<Regex>,
},
Number {
int: bool,
min: Option<f64>,
max: Option<f64>,
},
Boolean,
Array {
of: Box<Schema>,
min: Option<f64>,
max: Option<f64>,
},
Object {
fields: Vec<(String, Schema)>,
strict: bool,
},
Enum(Vec<String>),
Const(ConstValue),
Nullable(Box<Schema>),
Default(Box<Schema>),
Optional(Box<Schema>),
Described {
inner: Box<Schema>,
description: String,
},
}Expand description
One compiled schema node. Bounds are f64 because JSON Schema bounds are numbers.
Variants§
String
type: string with optional minLength / maxLength (UTF-16 length) and
pattern.
Fields
Format
type: string with format: <name>, a named zod string format. The format
composes with minLength / maxLength / pattern, as the chained
z.email().min(…).regex(…) does.
Fields
format: StringFormatthe named format
Number
type: number, or type: integer (int: true), with optional minimum /
maximum.
Fields
Boolean
type: boolean
Array
type: array with an items schema (of) and optional minItems / maxItems.
Fields
Object
type: object: properties in declaration order; strict
(additionalProperties: false) rejects unknown keys.
Fields
Enum(Vec<String>)
enum: [...]: a closed set of strings.
Const(ConstValue)
const: <scalar>: an exact literal.
Nullable(Box<Schema>)
type: [T, "null"]: also admit null.
Default(Box<Schema>)
default: <value>: a missing value passes (the default substitutes).
Optional(Box<Schema>)
A property not listed in required: a missing value passes.
Described
description:, carried for Finding.hint. Validation ignores it.