File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,25 @@ val elementToValidate: JsonElement = loadJsonToValidate()
134
134
val valid = schema.validate(elementToValidate, errors::add)
135
135
```
136
136
137
+ You can also use predefined ` ValidationOutput ` s to collect the results.
138
+ Output formats are defined in [ draft 2020-12] ( https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-12.4 ) .
139
+ The most performance can be achieved by using either ` flag ` or ` basic ` collectors.
140
+ The ` detailed ` and ` verbose ` provide more structured information but this adds additional cost to the validation process
141
+ (because they collect hierarchical output).
142
+
143
+ ``` kotlin
144
+ import io.github.optimumcode.json.schema.JsonSchema
145
+ import io.github.optimumcode.json.schema.OutputCollector
146
+ import io.github.optimumcode.json.schema.ValidationOutput.Flag
147
+ import io.github.optimumcode.json.schema.ValidationOutput.Basic
148
+ import io.github.optimumcode.json.schema.ValidationOutput.OutputUnit
149
+
150
+ val flag: Flag = schema.validate(elementToValidate, OutputCollector .flag())
151
+ val basic: Basic = schema.validate(elementToValidate, OutputCollector .basic())
152
+ val detailed: OutputUnit = schema.validate(elementToValidate, OutputCollector .detailed())
153
+ val verbose: OutputUnit = schema.validate(elementToValidate, OutputCollector .verbose())
154
+ ```
155
+
137
156
If you need to use more than one schema, and they have references to other schemas you should use ` JsonSchemaLoader ` class.
138
157
139
158
``` kotlin
You can’t perform that action at this time.
0 commit comments