Commit Graph

406 Commits (1b4cbcba3335a43561e91be4f2baa13c5902d44b)

Author SHA1 Message Date
Donald Pipowitch 6cc12130da Update ajv.d.ts 2017-02-21 14:55:57 +01:00
Evgeny Poberezkin 8413890875 fix: schema "dependencies" with property containing single quotes, closes #413 2017-02-12 00:21:53 +00:00
Evgeny Poberezkin ccc9907d26 feat: allow setting dataPath in validate/compile keywords, closes #331 2017-01-21 19:44:08 +00:00
Evgeny Poberezkin 7148ae3607 docs: update typings for "modifying" and "valid" custom keywords, #392, #393 2017-01-20 23:25:45 +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
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 c4335abf53 fix: allOf with empty schemas failing compilation, fixes #381 2016-12-24 23:42:36 +00:00
Evgeny Poberezkin 17de8aba47 fix: error macro 2016-12-24 02:23:12 +00:00
Evgeny Poberezkin c02a3bdc48 refactor: clean up keyword templates 2016-12-23 22:02:41 +00:00
Evgeny Poberezkin 23f2572d1c fix: formats json-pointer and relative-json-pointer now support empty fragments 2016-12-23 17:34:25 +00:00
Evgeny Poberezkin 8a470f32df docs: getKeyword, removeKeywords methods 2016-12-11 12:38:13 +00:00
Evgeny Poberezkin 7bfc868816 test: getKeyword, removeKeyword methods 2016-12-11 12:12:27 +00:00
Evgeny Poberezkin 506370804a feat: get and remove custom keywords from the Ajv instance, related to #371 2016-12-11 11:17:37 +00:00
Evgeny Poberezkin 5081be2720 refactor: make variable for package names local, closes #325, #117 2016-12-06 21:29:02 +00:00
Minchenko Valery 06fdf7175e Store require paths for optional dependencies in variables
remove warnings about missing dpendencies for webpack
2016-12-06 16:44:11 +03:00
Evgeny Poberezkin 1c3762c0e8 fix: remove duplicated return from generated code, correct error message 2016-12-02 17:48:56 +00:00
Evgeny Poberezkin 00bf5c77ee fix: compare Date and RegExp objects, closes #342 2016-11-14 18:27:40 +00:00
Evgeny Poberezkin 81c2069354 fix: type definition for option unknownFormats 2016-10-20 00:29:10 +01:00
Evgeny Poberezkin d54d92411c fix: simplify #326 2016-10-19 08:24:30 +01:00
Etai Gross ac4331b450 fix #326 by lazy-requiring js-beautify
only require beautify if the options are specified which would cause you to use it
2016-10-18 18:35:41 +03:00
Evgeny Poberezkin c55ef280dc feat: optionally fail validation of unknown format passed via $data, #310 2016-10-16 16:11:25 +01:00
Evgeny Poberezkin 9bd850d115 feat: optionally throw exception during schema compilation if unknown format is used, #310 2016-10-16 11:57:49 +01:00
Evgeny Poberezkin 40319b9e22 fix: message about changing default for extendRefs option, #303 2016-10-05 18:21:36 +01:00
Evgeny Poberezkin a3ab001d5b fix: do NOT log warning if extendRef is explicitely set to true, fix schema path in messages; closes #303 2016-10-05 18:11:31 +01:00
Evgeny Poberezkin 72a3bd0c2a fix: allow segments of hostnames to start with digit, closes #312 2016-10-02 18:21:17 +01:00
Evgeny Poberezkin 7c95ec9fa8 fix: escaped characters in $refs, closes #311 2016-09-28 14:28:52 +01:00
Evgeny Poberezkin 812940d528 feat: only store patterns and defaults if option sourceCode is true 2016-09-24 16:11:29 +01:00
Evgeny Poberezkin 5193d45fdc feat: add used defaults and patterns to validation function to support ajv-pack, #156 2016-09-24 15:58:14 +01:00
Evgeny Poberezkin cdd30a9776 fix: allow null as schema value in keywords that support $data reference (constant) 2016-09-22 15:40:38 +01:00
Evgeny Poberezkin acfd035720 refactor: replaced remaining eval with Function constructor 2016-09-19 20:16:27 +01:00
Darcy Parker fd07efc4cf Add missing rootData parameter from ValidateFunction typescript interface (#301)
* Add missing rootData property from ValidateFunction typescript interface

* Made change @epoberezkin requested
2016-09-19 12:49:37 +01:00
Evgeny Poberezkin d272e05abe refactor: rename option to sourceCode, #293 2016-09-06 21:48:42 +01:00
Russ Frank 792590b7b8 appease linter 2016-09-01 15:00:32 -07:00
Russ Frank 7d1e4d2c83 Add option to not retain validator source code
I noticed that in a program with many schemas, a large amount of memory
was taken up by the source code strings used to compile the validators.
This commit adds an option, `retainSourceCode`, default true, which
allows source code strings to be left out of the heap.
2016-08-31 16:25:00 -07:00
Evgeny Poberezkin 9dff6474d7 feat: pass schema compilation context (it) to compiled and macro custom keyword functions, closes #280 2016-08-29 22:56:07 +01:00
Evgeny Poberezkin 00f315c31f feat: allowedValues param in "enum" keyword error, closes #282 2016-08-29 22:42:16 +01:00
Evgeny Poberezkin 3806b9d8a3 fix: correctly resolve $data refs with absolute JSON pointers, #289 2016-08-29 22:26:33 +01:00
Evgeny Poberezkin 33081b4911 feat: pass rootData to validating functions as 5th parameters, related to #289 2016-08-29 21:52:05 +01:00
Don Rouse 53e9971edd Add JSON pointer support to $data reference. 2016-08-25 21:35:35 -07:00
Evgeny Poberezkin 7e7219212d feat: allow refs with protocol-relative URIs, closes #277 2016-08-15 21:53:09 +01:00
Evgeny Poberezkin 2d9241a658 feat: allow refs to fragments in "getSchema" and "validate" methods, closes #47 2016-08-15 21:22:07 +01:00
Evgeny Poberezkin 84b900889f refactor: function to check that schema has no rules except one specified (e.g. $ref) 2016-08-07 11:05:27 +01:00
Evgeny Poberezkin c103dc04b9 feat: support validating [meta-]schemas against themselves, closes #259 2016-08-07 00:37:30 +01:00
Evgeny Poberezkin 804764dbec Merge pull request #266 from epoberezkin/extend-refs
Option "extendRefs"
2016-08-06 22:13:12 +01:00
Evgeny Poberezkin 3185847572 feat: log warning if other keywords are used with "$ref", #260 2016-08-06 21:10:57 +01:00
Evgeny Poberezkin 39b4a8f637 feat: option "extendRefs" to fail compilation or to ignore other keywords when "$ref" is used, closes #260 2016-08-06 13:05:39 +01:00
Evgeny Poberezkin 27c612755a Merge pull request #263 from dalcib/master
[typescript] Allow use 'new' operator
2016-08-06 00:06:39 +01:00