Commit Graph

476 Commits (master)

Author SHA1 Message Date
Evgeny Poberezkin 917f20c5c3 test: draft-06 tests from JSON-Schema-Test-Suite 2017-02-26 19:35:26 +00:00
Evgeny Poberezkin ac27a2473d feat: uri should be absolute, relative uri-ref is not valid uri 2017-02-25 22:35:36 +00:00
Evgeny Poberezkin 376cc172b4 feat: extendRefs: "ignore" by default 2017-02-25 21:43:55 +00:00
Evgeny Poberezkin 3c86da4f1b fix: improve error reporting from oneOf keyword, closes #427 2017-02-25 21:16:55 +00:00
Evgeny Poberezkin 16bf5946fe fix: support required with $data/many properties with ownProperties option, #197 2017-02-12 17:58:18 +00:00
Evgeny Poberezkin 176ed87c33 fix: support schema dependencies with ownProperties option, #197 2017-02-12 00:36:14 +00:00
Evgeny Poberezkin 647cd6eccb Merge branch 'master' into 5.0.0 2017-02-12 00:26:33 +00:00
Evgeny Poberezkin 8413890875 fix: schema "dependencies" with property containing single quotes, closes #413 2017-02-12 00:21:53 +00:00
Evgeny Poberezkin 1babc9df49 fix: support property dependecies with ownProperties option, #197 2017-02-12 00:02:56 +00:00
Evgeny Poberezkin df6ef691ae fix: ownProperties option with required keyword, #197 2017-02-11 23:44:59 +00:00
Evgeny Poberezkin 57fc360285 test: ownProperties option with properties and required keywords, #197 2017-02-11 23:23:48 +00:00
Evgeny Poberezkin ea5b7008ae fix: support ownProperties option with properties keyword, #197 2017-02-11 23:11:41 +00:00
Evgeny Poberezkin dbe863032a test: failing tests for ownProperties option (skipped), #197 2017-02-11 22:31:37 +00:00
Evgeny Poberezkin c9fb5cafb9 refactor: tests for ownProperties option, #197 2017-02-11 22:20:46 +00:00
Evgeny Poberezkin 6bf7d19ff2 test: number format via $data, #291 2017-02-10 21:59:20 +00:00
Evgeny Poberezkin 901343c95d feat: support formats with $data for numbers, #291 2017-02-10 21:52:51 +00:00
Evgeny Poberezkin c21cbee56f fix: support multiple types for format, #291 2017-02-10 20:53:13 +00:00
Evgeny Poberezkin 1d84987baa Merge ssh://github.com/nimerritt/ajv into nimerritt-master 2017-02-10 19:59:27 +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 de0c827dec feat: throw exception if schema id is not a string and report error, closes #380 2017-02-04 22:36:21 +00:00
Evgeny Poberezkin f5bcd5735a fix: code clean-up, closes #388 2017-02-04 22:15:23 +00:00
Evgeny Poberezkin ca6916385b feat: throw exception if $schema is not a string, closes #394 2017-02-04 21:30:26 +00:00
Gajus Kuizinas e7de15c60b Revert "test: remove invalid test cases"
This reverts commit af37a943cc.
2017-01-25 22:26:31 +00:00
Gajus Kuizinas 5a374ed7b7 test: correct test format 2017-01-25 20:30:26 +00:00
Gajus Kuizinas af37a943cc test: remove invalid test cases
These cases are not expected to pass using the current regex.
2017-01-25 20:19:16 +00:00
Gajus Kuizinas 625bed10d2 test: add test cases for URL format 2017-01-25 20:00:05 +00:00
Evgeny Poberezkin 254c2672d5 feat: format uri-template, #384 2017-01-23 22:08:05 +00:00
Evgeny Poberezkin e949b8462c test: patternGroups with meta; meta: false warns insead of throwing meta-schema validation 2017-01-23 20:16:38 +00:00
Evgeny Poberezkin 8bb3b52f55 feat: serialize option, closes #385, closes #341 2017-01-21 20:28:50 +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 41ecdaff7c refactor: contains implemented as a standard keyword, #367 2016-12-30 17:44:18 +00:00
Evgeny Poberezkin 988fcfbbca test: numeric exclusiveMaximum/Minimum together with maximum/minimum, both as $data 2016-12-29 20:36:45 +00:00
Evgeny Poberezkin 19512861d2 feat: support numeric exclusiveMaximum/Minimum with $data, #367 2016-12-29 19:44:08 +00:00
Evgeny Poberezkin 4a9d765e5a feat: support numeric exclusiveMaximum/Minimum (no $data support yet), #367 2016-12-28 23:08:25 +00:00
Evgeny Poberezkin 6f2cea2244 refactor: support for transpile option moved to ajv-async package, #383 2016-12-26 20:57:14 +00:00
Evgeny Poberezkin c6d5c31ab4 style: convert eslintrc files to yml 2016-12-26 17:58:38 +00:00
Evgeny Poberezkin fc1c46cbfa feat: option processCode replaced option beautify, closes #382 2016-12-26 16:57:06 +00:00
Evgeny Poberezkin 850b50523c feat: async validation promise resolves with data in case of success, closes #377 2016-12-25 20:24:36 +00:00
Evgeny Poberezkin f1028c8411 feat: support boolean schemas in $ref 2016-12-25 17:43:26 +00:00
Evgeny Poberezkin 5503fe3553 test: enable test that was failing 2016-12-25 00:28:59 +00:00
Evgeny Poberezkin ac6097f285 Merge branch 'master' into 5.0.0 2016-12-25 00:22:01 +00:00
Evgeny Poberezkin c4335abf53 fix: allOf with empty schemas failing compilation, fixes #381 2016-12-24 23:42:36 +00:00
Evgeny Poberezkin 484df70eb5 feat: support boolean schemas, #367 2016-12-24 23:04:07 +00:00
Evgeny Poberezkin 559efa2b49 feat: support dependencies keyword with empty array of required properties, #367 2016-12-24 16:21:34 +00:00
Evgeny Poberezkin 82775ee8de feat: draft6 propertyName keyword (standard, inline) 2016-12-23 23:45:48 +00:00
Evgeny Poberezkin 416f294350 Merge branch 'master' into 5.0.0 2016-12-23 19:47:01 +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 9f487e2833 refactor: rename keyword "constant" to "const", #367 2016-12-21 21:50:10 +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 afd02f1f72 refactor: patternGroups deprecated, requires option to use, #371 2016-12-20 20:33:51 +00:00
Evgeny Poberezkin 7bfc868816 test: getKeyword, removeKeyword methods 2016-12-11 12:12:27 +00:00
Evgeny Poberezkin f3577a3b34 refactor: moved switch, patternRequired, formatMinimum/Maximum to ajv-keywords, #371 2016-12-10 22:00:42 +00:00
Evgeny Poberezkin 34b0101eb6 Merge branch 'master' into 5.0.0 2016-12-10 20:45:08 +00:00
Evgeny Poberezkin 3e666bc250 test: fix typo in file name 2016-12-03 19:26:30 +00:00
Evgeny Poberezkin eb8353ce6a Merge branch 'master' into 5.0.0 2016-11-30 20:50:56 +00:00
Nicholas Merritt ac20d32eea WIP 2016-11-25 23:20:20 +01:00
Evgeny Poberezkin 00bf5c77ee fix: compare Date and RegExp objects, closes #342 2016-11-14 18:27:40 +00:00
Evgeny Poberezkin 84b0531e39 feat: async loading of meta-schema, #334 2016-11-08 00:49:29 +00:00
Evgeny Poberezkin f95b83d890 test: failing test for #334, async loading of meta-schema 2016-11-07 22:44:56 +00:00
Evgeny Poberezkin a9e77e2904 test: failing test for #273, incorrect schemaPath in referenced schema 2016-11-07 21:53:56 +00:00
Evgeny Poberezkin 2b2e64488b test: compileAsync tests using promises, #249 2016-10-17 23:25:29 +01:00
Evgeny Poberezkin f4a5f1005c refactor: compileAsync returns promise; loadSchema option must return promise, #249 2016-10-17 22:52:24 +01:00
Evgeny Poberezkin c86e1bbc02 feat: make option unknownFormats default to true, closes #324 2016-10-16 18:59:40 +01:00
Evgeny Poberezkin aa09a89e6c Merge branch 'master' into 5.0.0 2016-10-16 17:43:22 +01:00
Evgeny Poberezkin eefa467446 test: not whitelisted unknown format in $data fails validation, #310 2016-10-16 16:11:44 +01: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 01ff755d4b test: whitelisted unknown formats should be valid (remove warnings), #310 2016-10-16 12:32:44 +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 0944949b08 test: option unknownFormats, #310 2016-10-16 11:32:12 +01:00
Evgeny Poberezkin 03051f90ba feat: log errors using console.error/warn, closes #265 2016-10-05 20:50:37 +01:00
Evgeny Poberezkin 3e50b5da3c feat: make option sourceCode default to false, closes #309 2016-10-05 20:36:49 +01:00
Evgeny Poberezkin 0bdb5a4fa5 feat: make option extendRef default to "fail", closes #294 2016-10-05 20:14:11 +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 da24fd33e1 test: refactor schema tests, use nyc 2016-10-04 21:16:18 +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 cdd30a9776 fix: allow null as schema value in keywords that support $data reference (constant) 2016-09-22 15:40:38 +01:00
Evgeny Poberezkin 1c28d6dc34 test: sourceCode option, #293 2016-09-06 21:49:01 +01:00
Evgeny Poberezkin 3806b9d8a3 fix: correctly resolve $data refs with absolute JSON pointers, #289 2016-08-29 22:26:33 +01:00
Don Rouse c6e42e7e5c Add tests for $data ref with absolute JSON pointers 2016-08-26 17:36:37 -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 86114c56dd style: no empty parens in constructor calls 2016-08-07 11:31:55 +01:00
Evgeny Poberezkin c103dc04b9 feat: support validating [meta-]schemas against themselves, closes #259 2016-08-07 00:37:30 +01:00
Evgeny Poberezkin b9a2e5907d test: increase timeout 2016-08-06 21:36:07 +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 3011bff559 test: option "extendRefs", #260 2016-08-06 11:44:18 +01:00
Evgeny Poberezkin 321a6d1a83 fix: date-time validation, closes #261 2016-08-05 11:57:58 +01:00
Victor Emanouilov 6df7b2040b fix: date-time string validation to fail validating for date-only strings instead of throwing a TypeError 2016-08-04 13:49:53 +03:00
Evgeny Poberezkin 62eaf92c4c
test: more test cases for coersion of array to scalar, #158 2016-07-28 22:23:18 +01:00
Evgeny Poberezkin b853218249
style: eslint tests, closes #250 2016-07-28 00:50:30 +01:00
Evgeny Poberezkin 0630539aa3
test: coerceTypes: "array" coercion should fail if array length != 1, #158 2016-07-27 22:17:06 +01:00
will Farrell a21cf02f43 update `==`, `object <-> array` 2016-07-26 14:43:20 -06:00
will Farrell ec09c3c735 allow reversal and add more tests 2016-07-24 19:03:27 -06:00
will Farrell 9e18e68ce7 Add in ability to coerce to an array 2016-07-22 18:07:10 -06:00
Evgeny Poberezkin d64b84f5ff
Merge branch 'master' into 4.2 2016-07-22 15:00:44 +01:00
Evgeny Poberezkin ac5c746f0a
Revert "Revert "feat: meta schema for custom keywords schemas, closes #230""
This reverts commit 09879d21ad.
2016-07-22 14:49:43 +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 f06008a84f
fix: error when mutually recursive fragment refs reference a common schema, closes #240 2016-07-22 00:37:35 +01:00
Evgeny Poberezkin c2609392a2
test: passing/failing tests for #240 - mutually recursive fragment refs reference a common schema 2016-07-21 23:08:42 +01:00
Evgeny Poberezkin 7f5fe70cdb
feat: $data support in custom keywords, #146 2016-07-19 22:50:10 +01:00
Evgeny Poberezkin 09879d21ad
Revert "feat: meta schema for custom keywords schemas, closes #230"
This reverts commit 1a6e4b576c.
2016-07-18 18:51:57 +01:00
Evgeny Poberezkin 1a6e4b576c
feat: meta schema for custom keywords schemas, closes #230 2016-07-17 11:20:47 +01:00
Evgeny Poberezkin 2bcb74fc8c
fix: support mutual recursive refs when both refs are schema fragments, closes #210 2016-07-10 18:36:09 +01:00
Evgeny Poberezkin 57e09aab22
test: control characters in "enum" and "dependencies", #226 2016-07-09 23:39:26 +01:00
Evgeny Poberezkin 7e0482619d
fix: support control characters in "properties" and "required", closes #226 2016-07-09 23:16:24 +01:00
Evgeny Poberezkin 28711287ff
test: failing test for #226: control chars in schema JSON 2016-07-08 22:11:24 +01:00
Evgeny Poberezkin 3f96062745 fix: ref resolution does not fail when it should; closes #220 2016-06-28 21:30:55 +01:00
Evgeny Poberezkin aa2ee31381 test: sync failing test for issue #220 2016-06-28 21:17:07 +01:00
Evgeny Poberezkin 5e7094754f test: failing test for issue #220 2016-06-28 21:09:04 +01:00
Evgeny Poberezkin 11c3f1483b failing test for issue #210 2016-06-18 22:15:39 +01:00
Evgeny Poberezkin 8c0b3d8321 fix custom keyword that defines errors, closes #181 2016-06-11 12:00:10 +01:00
Evgeny Poberezkin 6a14e347c4 use new with Ajv constructor in tests and examples 2016-06-04 21:16:11 +01:00
Evgeny Poberezkin dbf1b06c66 test for issue #204 (options schemas and v5) 2016-06-01 07:07:34 +01:00
Matt Broadstone 84ef7ab728 feat(own-properties): support optionally checking own properties
Traditionally ajv validates additionalProperties by checking all
enumerable properties of an object. This patch allows the user to
specify that they only want own properties of an object to be
considered in this validation
2016-05-26 17:50:52 -04:00
Evgeny Poberezkin 81f442b325 NaN validation, closes #182 2016-05-16 22:05:08 +01:00
Evgeny Poberezkin a8af73f45f fix incorrect change of resolution scope when sibling subschema has id in switch keyword, issue #170 2016-04-23 19:36:47 +01:00
Evgeny Poberezkin 07f344e752 fix incorrect change of resolution scope when sibling subschema has id in allOf, oneOf, anyOf and dependencies keywords, issue #170 2016-04-23 17:00:32 +01:00
Evgeny Poberezkin a2610bca0d fix incorrect change of resolution scope when sibling schema has id, closes #170 2016-04-23 14:56:16 +01:00
Evgeny Poberezkin 939ae53f7d failing test for #170 (ref resolution when sibling has id) 2016-04-23 13:49:23 +01:00
Evgeny Poberezkin 44dd6b78b9 Android 4 compatibility, #143 2016-04-18 21:15:38 +01:00
Evgeny Poberezkin 9fd6ac8044 test timeout 2016-04-15 22:35:19 +01:00
Evgeny Poberezkin 8020465d74 Merge branch 'master' into v4.0 2016-04-15 22:20:40 +01:00
Evgeny Poberezkin 26964e4996 Merge pull request #150 from lyngaas/format-exclusive-names
Rename exclusiveFormat to formatExclusive (v5 draft)
2016-04-15 22:16:30 +01:00
Evgeny Poberezkin b92e6e86a7 property dependencies in allErrors mode create error for each missing dependency; #151, closes 73 2016-04-15 22:10:30 +01:00
Evgeny Poberezkin d3d31d285a Merge branch 'master' into v4.0 2016-04-10 20:03:03 +01:00
Evgeny Poberezkin 19f94a1cd3 aditional coercion test (#152) 2016-03-25 20:45:53 +00:00
Evgeny Poberezkin e6a22be556 fix type coercion for multiple items/properties; closes #152 2016-03-25 20:13:39 +00:00
Evgeny Poberezkin cbd9467bd6 useDefaults: use literals (deep-clone) of defaults unless useDefaults: "shared" is passed, #151, #136 2016-03-24 23:27:13 +00:00
Ståle Lyngaas 98368bc363 Rename exclusiveFormat to formatExclusive (v5 draft) 2016-03-22 19:40:15 +01:00
Evgeny Poberezkin ce86641657 pass default meta-schema via "meta" option, closes #90 2016-03-14 20:56:07 +00:00
Evgeny Poberezkin d7bbf33478 bump version 2016-03-07 06:49:51 +00:00
Evgeny Poberezkin d47ff8b843 Merge pull request #136 from imbstack/dont-alter-underlying
Clone default values to avoid seemingly surprising behavior
2016-03-03 19:40:49 +00:00
Brian Stack bf76acfc21 Make cloning optional and based on stringify 2016-03-03 11:23:49 -08:00
Evgeny Poberezkin a7a4ac57bd fixed instances list for async test; readme re removeAdditional (related to #129, #134) 2016-03-03 00:28:44 +00:00
Brian Stack 4928b76605 Add failing test to reveal surprising behavior 2016-03-02 09:59:17 -08:00
Evgeny Poberezkin 71fafc27a4 fixed browsers async tests 2016-03-02 14:56:56 +00:00
Evgeny Poberezkin f4ca190010 fixed browser tests for async validation 2016-03-02 07:09:11 +00:00
Evgeny Poberezkin 700cfb01a6 exclude es7.regenerator async test when running in Safari 2016-03-01 20:44:41 +00:00
Evgeny Poberezkin bb243695c6 removed browser test badge 2016-02-29 23:47:15 +00: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 3aaeaf6ec0 removeSchema with RegExp to remove multiple schemas or without argument to remove all schemas, closes #103 2016-02-28 01:16:48 +00:00
Evgeny Poberezkin f48efb564a optimised "not" keyword in {allErrors: true} mode to fail on the first error in subschema, closes #131 2016-02-27 23:01:03 +00:00