Skip to content

Commit

Permalink
Clarify validation errors and fix link for useDefaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjones1 committed May 16, 2022
1 parent 99e884d commit 6ecf814
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ Options can have properties `separator` (string used to separate errors, ", " by

In case of validation failure, Ajv assigns the array of errors to `errors` property of validation function (or to `errors` property of Ajv instance when `validate` or `validateSchema` methods were called). In case of [asynchronous validation](./guide/async-validation.md), the returned promise is rejected with exception `Ajv.ValidationError` that has `errors` property.

Note, the `errors` property may not be set if validation fails due to a missing property, even if it is not required in the schema. In these cases, consider using [option `useDefaults`](./options.md#options).

### Error objects

Each reported error is an object with the following properties:
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/modifying-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ See [discriminator](../json-schema.md#discriminator) keyword.

## Assigning defaults

With [option `useDefaults`](./api.md#options) Ajv will assign values from `default` keyword in the schemas of `properties` and `items` (when it is the array of schemas) to the missing properties and items.
With [option `useDefaults`](./options.md#options) Ajv will assign values from `default` keyword in the schemas of `properties` and `items` (when it is the array of schemas) to the missing properties and items.

With the option value `"empty"` properties and items equal to `null` or `""` (empty string) will be considered missing and assigned defaults.

Expand Down

0 comments on commit 6ecf814

Please sign in to comment.