maximum/minimum keywords optimized

master
Evgeny Poberezkin 2015-06-15 11:14:13 +01:00
parent 106826146e
commit 5582e13c1d
4 changed files with 8 additions and 6 deletions

View File

@ -3,9 +3,10 @@
{{
var $exclusive = it.schema.exclusiveMaximum === true
, $op = $exclusive ? '<' : '<=';
, $op = $exclusive ? '<' : '<=' /*used in error*/
, $notOp = $exclusive ? '>=' : '>';
}}
if (! ({{=$data}} {{=$op}} {{=$schema}}) ) {
if ({{=$data}} {{=$notOp}} {{=$schema}}) {
{{# def.error:'maximum' }}
} {{? $breakOnError }} else { {{?}}

View File

@ -1,6 +1,6 @@
{{# def.definitions }}
{{# def.setup:'minItems' }}
if ({{=$data}}.length < {{=$schema}}) {
if ({{=$data}}.length < {{=$schema}}) {
{{# def.error:'minItems' }}
} {{? $breakOnError }} else { {{?}}

View File

@ -3,9 +3,10 @@
{{
var $exclusive = it.schema.exclusiveMinimum === true
, $op = $exclusive ? '>' : '>=';
, $op = $exclusive ? '>' : '>=' /*used in error*/
, $notOp = $exclusive ? '<=' : '<';
}}
if (!( {{=$data}} {{=$op}} {{=$schema}} )) {
if ({{=$data}} {{=$notOp}} {{=$schema}}) {
{{# def.error:'minimum' }}
} {{? $breakOnError }} else { {{?}}

View File

@ -1,6 +1,6 @@
{
"name": "ajv",
"version": "0.4.6",
"version": "0.4.7",
"description": "Another JSON schema Validator",
"main": "lib/ajv.js",
"scripts": {