Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move max*, min* keywords to the new definition format witho…
…ut doT templates
- Loading branch information
1 parent
971d9f9
commit 43d80f6
Showing
30 changed files
with
106 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
module.exports = Cache | ||
|
||
function Cache() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
var MissingRefError = require("./error_classes").MissingRef | ||
|
||
module.exports = compileAsync | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
// do NOT remove this file - it would break pre-compiled schemas | ||
// https://github.com/ajv-validator/ajv/issues/889 | ||
module.exports = require("fast-deep-equal") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
var resolve = require("./resolve") | ||
|
||
module.exports = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
var URI = require("uri-js"), | ||
equal = require("fast-deep-equal"), | ||
util = require("./util"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
var util = require("./util") | ||
|
||
module.exports = SchemaObject | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
// TODO use $data in keyword definitions | ||
var KEYWORDS = [ | ||
"multipleOf", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
"use strict" | ||
|
||
var metaSchema = require("./refs/json-schema-draft-07.json") | ||
|
||
module.exports = { | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {concatSchema, dataNotType} = require("../compile/util") | ||
|
||
const SCHEMA_TYPE = "number" | ||
|
||
module.exports = { | ||
keywords: ["maxItems", "minItems"], | ||
type: "array", | ||
schemaType: SCHEMA_TYPE, | ||
$data: true, | ||
code({fail, keyword, data, $data, schemaCode}) { | ||
const op = keyword == "maxItems" ? ">" : "<" | ||
const dnt = dataNotType($data, schemaCode, SCHEMA_TYPE) | ||
fail(dnt + `${data}.length` + op + schemaCode) | ||
}, | ||
error: { | ||
message({keyword, $data, schemaCode}) { | ||
const comp = keyword == "maxItems" ? "more" : "fewer" | ||
const sch = concatSchema($data, schemaCode) | ||
return `"should NOT have ${comp} than ${sch} items"` | ||
}, | ||
params: ({schemaCode}) => `{limit: ${schemaCode}}`, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const {concatSchema, dataNotType} = require("../compile/util") | ||
|
||
const SCHEMA_TYPE = "number" | ||
|
||
module.exports = { | ||
keywords: ["maxLength", "minLength"], | ||
type: "string", | ||
schemaType: SCHEMA_TYPE, | ||
$data: true, | ||
code({fail, keyword, data, $data, schemaCode, opts}) { | ||
const op = keyword == "maxLength" ? ">" : "<" | ||
const dnt = dataNotType($data, schemaCode, SCHEMA_TYPE) | ||
const len = | ||
opts.unicode === false ? `${data}.length` : `ucs2length(${data})` | ||
fail(dnt + len + op + schemaCode) | ||
}, | ||
error: { | ||
message({keyword, $data, schemaCode}) { | ||
const comp = keyword == "maxLength" ? "more" : "fewer" | ||
const sch = concatSchema($data, schemaCode) | ||
return `"should NOT have ${comp} than ${sch} items"` | ||
}, | ||
params: ({schemaCode}) => `{limit: ${schemaCode}}`, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {concatSchema, dataNotType} = require("../compile/util") | ||
|
||
const SCHEMA_TYPE = "number" | ||
|
||
module.exports = { | ||
keywords: ["maxProperties", "minProperties"], | ||
type: "object", | ||
schemaType: SCHEMA_TYPE, | ||
$data: true, | ||
code({fail, keyword, data, $data, schemaCode}) { | ||
const op = keyword == "maxProperties" ? ">" : "<" | ||
const dnt = dataNotType($data, schemaCode, SCHEMA_TYPE) | ||
fail(dnt + `Object.keys(${data}).length` + op + schemaCode) | ||
}, | ||
error: { | ||
message({keyword, $data, schemaCode}) { | ||
const comp = keyword == "maxProperties" ? "more" : "fewer" | ||
const sch = concatSchema($data, schemaCode) | ||
return `"should NOT have ${comp} than ${sch} items"` | ||
}, | ||
params: ({schemaCode}) => `{limit: ${schemaCode}}`, | ||
}, | ||
} |
Oops, something went wrong.