Skip to content

Commit a71cece

Browse files
committed
docs: FAQ for additionalProperties error messages
Also add ajv-errors to the list of related packages.
1 parent 4504e97 commit a71cece

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

FAQ.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ No. There is no concurrency in JavaScript - it is single-threaded. While a valid
2525
No. In many cases there is a module responsible for the validation in the application, usually to load schemas and to process errors. This module is the right place to introduce any custom API. Convenience is a subjective thing, changing or extending API purely because of convenience would either break backward compatibility (even if it's done in a new major version it still complicates migration) or bloat API (making it more difficult to maintain).
2626

2727

28+
##### Why don't `"additionalProperties": false` errors display the property name?
29+
30+
Doing this would create a precedent where validated data is used in error messages, creating a vulnerability (e.g., when ajv is used to validate API data/parameters and error messages are logged).
31+
32+
Since the property name is already in the params object, in an application you can modify messages in any way you need. ajv-errors package will allow to modify messages as well - templating is [not there yet](https://github.com/epoberezkin/ajv-errors/issues/4), though.
33+
34+
2835
## Additional properties inside compound keywords anyOf, oneOf, etc.
2936

3037
See [#127](https://github.com/epoberezkin/ajv/issues/127), [#129](https://github.com/epoberezkin/ajv/issues/129), [#134](https://github.com/epoberezkin/ajv/issues/134), [#140](https://github.com/epoberezkin/ajv/issues/140), [#193](https://github.com/epoberezkin/ajv/issues/193), [#205](https://github.com/epoberezkin/ajv/issues/205), [#238](https://github.com/epoberezkin/ajv/issues/238), [#264](https://github.com/epoberezkin/ajv/issues/264).

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ Properties of `params` object in errors depend on the keyword that failed valida
11751175
- [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) - internationalised error messages
11761176
- [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) - keywords $merge and $patch.
11771177
- [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) - several custom keywords that can be used with Ajv (typeof, instanceof, range, propertyNames)
1178+
- [ajv-errors](https://github.com/epoberezkin/ajv-errors) - custom error messages for Ajv
11781179

11791180

11801181
## Some packages using Ajv

0 commit comments

Comments
 (0)