Closed maldimirov closed 4 years ago
I wonder if the best way to support this is to use the concept of "vendor" extensions.
For example:
{
"type": "string",
"x-additional-validation": ... capture somehow
}
Maybe, just enable something that lets people have a general catch-all for an x-
attribute which will invoke a function on an object under that key, pass the current schema to it. Could be used for almost anything - not just extending.
Well the original idea (which was inspired by the needs of our project) was to stay as close to native JSON Schema
and Joi
as possible. x-
attributes are not exactly native JSON Schema
, so they conflict with this idea. We can also extend the validation by writing validation logic ourselves outside of Enjoi
. I don't see what advantages would x-
attributes bring us in that case.
The advantage of using Joi
is the standardization of the validation definitions and the aggregation of all validation errors in one place. The latter being the bigger advantage and the main motivation for this PR.
I think at this point this needs to be closed. I believe this feature would now be supported by recent merged refineSchema
as well.
Resolves #65 + some small additions
enjoi
options
- an empty schema or one that is considered empty is valid, so the warning should be removable. Refer to https://json-schema.org/latest/json-schema-core.html#rfc.section.4.3.1. The default value of the option is left totrue
to avoid breaking changes.