Skip to content

Commit

Permalink
docs: update validation documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-tay committed Jun 29, 2024
1 parent 5177982 commit e10e99a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/utilities/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ You can validate inbound and outbound events using `@Validation` annotation.

You can also use the `Validator#validate()` methods, if you want more control over the validation process such as handling a validation error.

We support JSON schema version 4, 6, 7 and 201909 (from [jmespath-jackson library](https://github.com/burtcorp/jmespath-java)).
We support JSON schema version 4, 6, 7, 2019-09 and 2020-12 using the [NetworkNT JSON Schema Validator](https://github.com/networknt/json-schema-validator). ([Compatibility with JSON Schema versions](https://github.com/networknt/json-schema-validator/blob/master/doc/compatibility.md)).

The validator is configured to enable format assertions by default even for 2019-09 and 2020-12.

### Validation annotation

Expand Down Expand Up @@ -228,7 +230,8 @@ and [function](https://jmespath.org/tutorial.html#functions) expressions, where


## Change the schema version
By default, powertools-validation is configured with [V7](https://json-schema.org/draft-07/json-schema-release-notes.html).
By default, powertools-validation is configured to use [V7](https://json-schema.org/draft-07/json-schema-release-notes.html) as the default dialect if [`$schema`](https://json-schema.org/understanding-json-schema/reference/schema#schema) is not explicitly specified within the schema. If [`$schema`](https://json-schema.org/understanding-json-schema/reference/schema#schema) is explicitly specified within the schema, the validator will use the specified dialect.

You can use the `ValidationConfig` to change that behaviour.

=== "Handler with custom schema version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ public SpecVersion.VersionFlag getSchemaVersion() {
}

/**
* Set the version of the json schema specifications (default is V7)
* Set the version of the json schema specifications to use if $schema is not
* explicitly specified within the schema (default is V7). If $schema is
* explicitly specified within the schema is explicitly specified within the
* schema, the validator will use the specified dialect.
*
* @param version May be V4, V6, V7, V201909 or V202012
* @see <a href=
* "https://json-schema.org/understanding-json-schema/reference/schema#declaring-a-dialect">Declaring
* a Dialect</a>
*/
public void setSchemaVersion(SpecVersion.VersionFlag version) {
if (version != jsonSchemaVersion) {
Expand Down

0 comments on commit e10e99a

Please sign in to comment.