pub struct ValidateOptions { /* private fields */ }
Expand description
Options you can pass to validate()
.
Implementations§
Source§impl ValidateOptions
impl ValidateOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new set of options with all default values.
Equivalent to Default::default()
or calling with_max_depth(0)
and
with_max_errors(0)
.
Sourcepub fn with_max_depth(self, max_depth: usize) -> Self
pub fn with_max_depth(self, max_depth: usize) -> Self
Sets the maximum “depth” of references to following in validate()
.
This option exists to handle the possibility of an infinite loop in a schema. For instance, this is a valid schema:
{ "ref": "loop", "definitions": { "loop": { "ref": "loop" }}}
There are good reasons to sometimes have self-referential schemas – for
instance, to describe a recursive data structure. What with_max_depth
does is limit how many recursive ref
nodes will be followed before
validate()
errors with ValidateError::MaxDepthExceeded
.
The default max depth of 0
indicates that no max depth should be
implemented. An infinite ref
loop will eventually overflow the stack
during validate()
.
Sourcepub fn with_max_errors(self, max_errors: usize) -> Self
pub fn with_max_errors(self, max_errors: usize) -> Self
Sets the maximum number of validation errors to return from
validate()
.
This option exists as an optimization for validate()
. If all you
care about is whether an input is valid, then consider using
set_max_errors(1)
to have validate()
immediately return after
finding a validation error.
The default max errors of 0
indicates that all errors will be
returned.
Trait Implementations§
Source§impl Clone for ValidateOptions
impl Clone for ValidateOptions
Source§fn clone(&self) -> ValidateOptions
fn clone(&self) -> ValidateOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more