class JTD::ValidationOptions
Options you can pass to JTD::validate
.
Attributes
The maximum number of references to follow before aborting validation. You can use this to prevent a stack overflow when validating schemas that potentially have infinite loops, such as this one:
{ "definitions": { "loop": { "ref": "loop" } }, "ref": "loop" }
The default value for max_depth
is 0, which indicates that no max depth should be imposed at all.
The maximum number of errors to return. You can use this to have JTD::validate
have better performance if you don't have any use for errors beyond a certain count.
For instance, if all you care about is whether or not there are any validation errors at all, you can set max_errors
to 1. If you're presenting validation errors in an interface that can't show more than 5 errors, set max_errors
to 5.
The default value for max_errors
is 0, which indicates that all errors will be returned.
Public Class Methods
Construct a new set of ValidationOptions
with the given max_depth
and max_errors
.
See the documentation for max_depth
and max_errors
for what their default values of 0 mean.
# File lib/jtd/validate.rb, line 77 def initialize(max_depth: 0, max_errors: 0) @max_depth = max_depth @max_errors = max_errors end