feat: support numeric exclusiveMaximum/Minimum with $data, #367
parent
4a9d765e5a
commit
19512861d2
|
@ -16,22 +16,33 @@
|
||||||
{{
|
{{
|
||||||
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
||||||
, $exclusive = 'exclusive' + $lvl
|
, $exclusive = 'exclusive' + $lvl
|
||||||
|
, $exclType = 'exclType' + $lvl
|
||||||
|
, $exclIsNumber = 'exclIsNumber' + $lvl
|
||||||
, $opExpr = 'op' + $lvl
|
, $opExpr = 'op' + $lvl
|
||||||
, $opStr = '\' + ' + $opExpr + ' + \'';
|
, $opStr = '\' + ' + $opExpr + ' + \'';
|
||||||
}}
|
}}
|
||||||
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
||||||
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
||||||
|
|
||||||
var exclusive{{=$lvl}};
|
var {{=$exclusive}};
|
||||||
if (typeof {{=$schemaValueExcl}} != 'boolean' && typeof {{=$schemaValueExcl}} != 'undefined') {
|
var {{=$exclType}} = typeof {{=$schemaValueExcl}};
|
||||||
|
if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
|
||||||
{{ var $errorKeyword = $exclusiveKeyword; }}
|
{{ var $errorKeyword = $exclusiveKeyword; }}
|
||||||
{{# def.error:'_exclusiveLimit' }}
|
{{# def.error:'_exclusiveLimit' }}
|
||||||
} else if({{# def.$dataNotType:'number' }}
|
} else if ({{# def.$dataNotType:'number' }}
|
||||||
((exclusive{{=$lvl}} = {{=$schemaValueExcl}} === true)
|
{{=$exclType}} == 'number'
|
||||||
? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
|
? (
|
||||||
: {{=$data}} {{=$notOp}} {{=$schemaValue}})
|
({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
|
||||||
|
? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
|
||||||
|
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
||||||
|
)
|
||||||
|
: (
|
||||||
|
({{=$exclusive}} = {{=$schemaValueExcl}} === true)
|
||||||
|
? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
|
||||||
|
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
||||||
|
)
|
||||||
|| {{=$data}} !== {{=$data}}) {
|
|| {{=$data}} !== {{=$data}}) {
|
||||||
var op{{=$lvl}} = exclusive{{=$lvl}} ? '{{=$op}}' : '{{=$op}}=';
|
var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
|
||||||
{{??}}
|
{{??}}
|
||||||
{{
|
{{
|
||||||
var $exclIsNumber = typeof $schemaExcl == 'number'
|
var $exclIsNumber = typeof $schemaExcl == 'number'
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
},
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"skip": true,
|
|
||||||
"description": "below the exclusiveMaximum is valid",
|
"description": "below the exclusiveMaximum is valid",
|
||||||
"data": {
|
"data": {
|
||||||
"larger": 3,
|
"larger": 3,
|
||||||
|
@ -183,7 +182,6 @@
|
||||||
},
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"skip": true,
|
|
||||||
"description": "valid array",
|
"description": "valid array",
|
||||||
"data": ["", 0, 1, 2, 3, 4],
|
"data": ["", 0, 1, 2, 3, 4],
|
||||||
"valid": true
|
"valid": true
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
},
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"skip": true,
|
|
||||||
"description": "above the exclusiveMinimum is valid",
|
"description": "above the exclusiveMinimum is valid",
|
||||||
"data": {
|
"data": {
|
||||||
"smaller": 3,
|
"smaller": 3,
|
||||||
|
@ -176,7 +175,6 @@
|
||||||
},
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"skip": true,
|
|
||||||
"description": "valid array",
|
"description": "valid array",
|
||||||
"data": [1, 2, 3, 4, 5, 6],
|
"data": [1, 2, 3, 4, 5, 6],
|
||||||
"valid": true
|
"valid": true
|
||||||
|
|
Loading…
Reference in New Issue