diff --git a/lib/dot/_limit.jst b/lib/dot/_limit.jst index 6cac5da..9913e3f 100644 --- a/lib/dot/_limit.jst +++ b/lib/dot/_limit.jst @@ -16,22 +16,33 @@ {{ var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr) , $exclusive = 'exclusive' + $lvl + , $exclType = 'exclType' + $lvl + , $exclIsNumber = 'exclIsNumber' + $lvl , $opExpr = 'op' + $lvl , $opStr = '\' + ' + $opExpr + ' + \''; }} var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}}; {{ $schemaValueExcl = 'schemaExcl' + $lvl; }} - var exclusive{{=$lvl}}; - if (typeof {{=$schemaValueExcl}} != 'boolean' && typeof {{=$schemaValueExcl}} != 'undefined') { + var {{=$exclusive}}; + var {{=$exclType}} = typeof {{=$schemaValueExcl}}; + if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') { {{ var $errorKeyword = $exclusiveKeyword; }} {{# def.error:'_exclusiveLimit' }} - } else if({{# def.$dataNotType:'number' }} - ((exclusive{{=$lvl}} = {{=$schemaValueExcl}} === true) - ? {{=$data}} {{=$notOp}}= {{=$schemaValue}} - : {{=$data}} {{=$notOp}} {{=$schemaValue}}) + } else if ({{# def.$dataNotType:'number' }} + {{=$exclType}} == 'number' + ? ( + ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}}) + ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}} + : {{=$data}} {{=$notOp}} {{=$schemaValue}} + ) + : ( + ({{=$exclusive}} = {{=$schemaValueExcl}} === true) + ? {{=$data}} {{=$notOp}}= {{=$schemaValue}} + : {{=$data}} {{=$notOp}} {{=$schemaValue}} + ) || {{=$data}} !== {{=$data}}) { - var op{{=$lvl}} = exclusive{{=$lvl}} ? '{{=$op}}' : '{{=$op}}='; + var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}='; {{??}} {{ var $exclIsNumber = typeof $schemaExcl == 'number' diff --git a/spec/extras/$data/exclusiveMaximum.json b/spec/extras/$data/exclusiveMaximum.json index 260e713..dc23b8e 100644 --- a/spec/extras/$data/exclusiveMaximum.json +++ b/spec/extras/$data/exclusiveMaximum.json @@ -11,7 +11,6 @@ }, "tests": [ { - "skip": true, "description": "below the exclusiveMaximum is valid", "data": { "larger": 3, @@ -183,7 +182,6 @@ }, "tests": [ { - "skip": true, "description": "valid array", "data": ["", 0, 1, 2, 3, 4], "valid": true diff --git a/spec/extras/$data/exclusiveMinimum.json b/spec/extras/$data/exclusiveMinimum.json index b2537e8..9b361c0 100644 --- a/spec/extras/$data/exclusiveMinimum.json +++ b/spec/extras/$data/exclusiveMinimum.json @@ -11,7 +11,6 @@ }, "tests": [ { - "skip": true, "description": "above the exclusiveMinimum is valid", "data": { "smaller": 3, @@ -176,7 +175,6 @@ }, "tests": [ { - "skip": true, "description": "valid array", "data": [1, 2, 3, 4, 5, 6], "valid": true