Skip to content

Commit 2d84366

Browse files
committed
Update readme
1 parent 35f52e4 commit 2d84366

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ val elementToValidate: JsonElement = loadJsonToValidate()
134134
val valid = schema.validate(elementToValidate, errors::add)
135135
```
136136

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+
137156
If you need to use more than one schema, and they have references to other schemas you should use `JsonSchemaLoader` class.
138157

139158
```kotlin

0 commit comments

Comments
 (0)