Commit Graph

38 Commits (fdfbd4402a82ce63b220323794f64c51900d31d1)

Author SHA1 Message Date
Evgeny Poberezkin fdfbd4402a feat: support for required dependencies of custom keyword (keywords that must be present in the same schema) 2019-02-09 20:28:33 +00:00
Evgeny Poberezkin bf0fc0301e Revert "refactor: remove "equal" file"
This reverts commit f9fcc504a4.
2018-11-29 08:51:17 +00:00
Evgeny Poberezkin f9fcc504a4 refactor: remove "equal" file 2018-11-11 11:59:09 +00:00
Jonathan Stewmon 4865e6e894 support resolving internal refs from macro keywords 2018-06-25 15:31:37 -05:00
Philipp Thuerwaechter c9a6f995a9 Add method chaining to all add* and remove* methods
According to issue #625 this enables crazy things like
`new Ajv().addSchema(mySchema).validate(schema, data)`
2017-11-22 08:37:42 +01:00
Evgeny Poberezkin cbef7f3061 refactor: update draft-06 meta-schema, fix URI resolution, fix tests 2017-03-12 17:10:16 +00:00
Evgeny Poberezkin 03b24c72f8 fix: custom keywords with $data option validate as valid if their value (in data) is undefined 2017-02-05 17:40:39 +00:00
Evgeny Poberezkin a06327eab4 Merge branch 'master' into 5.0.0 2017-01-20 23:30:54 +00:00
Evgeny Poberezkin aa8de572df feat: custom keywords with predefined validation result, #393 2017-01-20 23:08:52 +00:00
Evgeny Poberezkin 33845cc397 feat: support custom keywords that modify data, #392 2017-01-20 22:03:36 +00:00
Evgeny Poberezkin 2468bd5014 refactor: custom keyword code generation, #392 2017-01-20 21:33:34 +00:00
Evgeny Poberezkin 82002ec5e8 test: failing test for custom keyword mutating data, #141, #392 2017-01-20 20:26:14 +00:00
Richard Taylor b1b0c553d8 Improve implementation of allowing hyphens in keywords
This:
- Updates the README with the new rules (and recommendations)
- Updates `keyword.js` to implement the agreed change to the naming rules:
- - Now same as before but also allow hyphens as second and subsequent characters
- Update tests to test the new keyword naming rules
- Update `definitions.def` to use it.util.getProperty() to dynamically choose dot
  or bracket notation as appropriate rather than hardcode bracket notation.

Test Plan:
- Run `npm test` and ensure all tests run and pass
2017-01-05 18:28:28 +00:00
Richard Taylor 66db560ca5 Allow custom keywords that are not valid JS identifiers
Custom keywords were required to be valid JS identifiers due to the
way they were being used in the generated code.  This prevented the use
of keywords with the `x-` prefix that is required by [swagger](http://swagger.io].

This change fixes that by updating the only place that was using them
directly as an identifier to use //brackets// notation rather than
//dot// notation.  This brings the definition of `$schemaPath` in
`definitions.def` in line with the way the rule definition is accessed
from `RULES.custom` at the top of `custom.jst`.

The validation of the keyword name has been changed to allow any name
in this change, but this should be updated to either just remove the
test or update it to a new rule before this change is included in
the project.

Finally, this also updates a number of the tests in `custom.spec.js` to
use non-valid identifiers for the names of some of the custom keywords
being tested (primarily by adding `x-` to the front of the name).

Test Plan:
- Run `npm test` and ensure all tests run and pass
2017-01-05 10:48:12 +00:00
Evgeny Poberezkin 416f294350 Merge branch 'master' into 5.0.0 2016-12-23 19:47:01 +00:00
Evgeny Poberezkin ab488a4f57 feat: option $data instead of v5, use draft-6 meta schema, support constant and contains keywords by default, #372 2016-12-21 21:11:59 +00:00
Evgeny Poberezkin 7bfc868816 test: getKeyword, removeKeyword methods 2016-12-11 12:12:27 +00:00
Evgeny Poberezkin b853218249
style: eslint tests, closes #250 2016-07-28 00:50:30 +01:00
Evgeny Poberezkin 5a80c7cff6
feat: support meta-schema validation in custom keywords with $data support, #146 2016-07-22 14:25:41 +01:00
Evgeny Poberezkin 7f5fe70cdb
feat: $data support in custom keywords, #146 2016-07-19 22:50:10 +01:00
Evgeny Poberezkin 1a6e4b576c
feat: meta schema for custom keywords schemas, closes #230 2016-07-17 11:20:47 +01:00
Evgeny Poberezkin 53a6c70138 asynchronous custom keywords can define custom errors by returning the promise that rejects with Ajv.ValidationError, closes #118 2016-02-28 22:14:18 +00:00
Evgeny Poberezkin 27bd49f182 renamed opts property of ajv instance to _opts; options object passed to constructor is copied 2016-01-25 06:37:36 +00:00
Evgeny Poberezkin 2eef59dede minified browser bundle 2015-12-27 21:33:07 +00:00
Evgeny Poberezkin 694e81684f throw exception if custom keyword is not an identifier; update tests as macro keyword definition supports type 2015-12-26 23:04:45 +00:00
Evgeny Poberezkin c4786866e2 simplify compiling macro keywords 2015-12-26 22:27:13 +00:00
Evgeny Poberezkin 10c6685027 support $data ref in formatMaximum/Minimum and exclusiveFormatMaximum/Minimum, #81 2015-12-24 17:43:48 +00:00
Evgeny Poberezkin abff815d38 refactored schema compilation to reduce browser bundle size 2015-12-23 01:50:11 +00:00
Evgeny Poberezkin 65e534ee8b check/extend errors in inline custom keywords; tests for custom keywords creating errors 2015-11-21 23:12:03 +00:00
Evgeny Poberezkin 771e79f36b readme: validation errors, inline custom keywords 2015-11-18 21:34:50 +00:00
Evgeny Poberezkin 982264f192 removed i18n option (params always added to error objects) 2015-11-17 23:45:19 +00:00
Evgeny Poberezkin 41f313a798 refactor custom keywords tests 2015-11-17 23:20:12 +00:00
Evgeny Poberezkin ee450ec8d0 removed caching of compiled subschemas of custom keywords (it made performance worse in most cases) 2015-11-17 23:20:12 +00:00
Evgeny Poberezkin ae5b4c0f45 support for "inline" custom keywords, #69 2015-11-17 23:20:12 +00:00
Evgeny Poberezkin 18c1ef858c support for "macro" custom keywords, #69 2015-11-17 23:20:11 +00:00
Evgeny Poberezkin 285850ce20 pass parent schema to compile/validate functions of custom keywords if they use it, #69 2015-11-17 23:17:59 +00:00
Evgeny Poberezkin 5e45d4eadf support compiling schemas in custom keywords, #69 2015-11-17 23:17:59 +00:00
Evgeny Poberezkin fcc776e794 basic implementation of custom keywords, #69 2015-11-17 23:17:59 +00:00