File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,26 @@ val valid = schema.validate(elementToValidate, errors::add)
354
354
The library supports ` format ` assertion.
355
355
All formats from [ JSON schema draft 2020-12] ( https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-7.3 ) are supported.
356
356
357
+ According to JSON schema specification the ` format ` keyword produces ** assertion by default** for all drafts ** before draft 2019-09** .
358
+ Starting ** from draft 2019-09** the ` format ` keyword produces only ** annotation by default** .
359
+
360
+ You can change the default behaviour by specifying the corresponding option in ` JsonSchemaLoader ` .
361
+ ``` kotlin
362
+ import io.github.optimumcode.json.schema.FormatBehavior.ANNOTATION_AND_ASSERTION
363
+ import io.github.optimumcode.json.schema.JsonSchemaLoader
364
+ import io.github.optimumcode.json.schema.SchemaOption
365
+
366
+ val schema = JsonSchemaLoader .create()
367
+ // option to change the default behavior
368
+ .withSchemaOption(SchemaOption .FORMAT_BEHAVIOR_OPTION , ANNOTATION_AND_ASSERTION )
369
+ // or
370
+ .withSchemaOption(SchemaOption .FORMAT_BEHAVIOR_OPTION , ANNOTATION_ONLY )
371
+ .fromDefinition(schemaDefinition)
372
+ ```
373
+
374
+ Alternatively, for drafts starting from the draft 2019-09 you can either use a custom meta-schema with format-assertion vocabulary enabled
375
+ and use this meta-schema in ` $schema ` property or define ` $vocabulary ` block with enabled format assertion in your schema.
376
+
357
377
** _ Implementation details:_ **
358
378
359
379
+ ** regex** - to implement regex format Kotlin ` Regex ` class is used.
You can’t perform that action at this time.
0 commit comments