3 {{# def.setupKeyword }}
6 {{## def.setExclusiveLimit:
8 $errorKeyword = $exclusiveKeyword;
9 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
13 var $isMax = $keyword == 'maximum'
14 , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
15 , $schemaExcl = it.schema[$exclusiveKeyword]
16 , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
17 , $op = $isMax ? '<' : '>'
18 , $notOp = $isMax ? '>' : '<'
19 , $errorKeyword = undefined;
21 if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
22 throw new Error($keyword + ' must be number');
24 if (!($isDataExcl || $schemaExcl === undefined
25 || typeof $schemaExcl == 'number'
26 || typeof $schemaExcl == 'boolean')) {
27 throw new Error($exclusiveKeyword + ' must be number or boolean');
33 var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
34 , $exclusive = 'exclusive' + $lvl
35 , $exclType = 'exclType' + $lvl
36 , $exclIsNumber = 'exclIsNumber' + $lvl
37 , $opExpr = 'op' + $lvl
38 , $opStr = '\' + ' + $opExpr + ' + \'';
40 var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
41 {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
44 var {{=$exclType}} = typeof {{=$schemaValueExcl}};
45 if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
46 {{ var $errorKeyword = $exclusiveKeyword; }}
47 {{# def.error:'_exclusiveLimit' }}
48 } else if ({{# def.$dataNotType:'number' }}
49 {{=$exclType}} == 'number'
51 ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
52 ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
53 : {{=$data}} {{=$notOp}} {{=$schemaValue}}
56 ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
57 ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
58 : {{=$data}} {{=$notOp}} {{=$schemaValue}}
60 || {{=$data}} !== {{=$data}}) {
61 var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
63 if ($schema === undefined) {
64 $errorKeyword = $exclusiveKeyword;
65 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
66 $schemaValue = $schemaValueExcl;
67 $isData = $isDataExcl;
72 var $exclIsNumber = typeof $schemaExcl == 'number'
73 , $opStr = $op; /*used in error*/
76 {{? $exclIsNumber && $isData }}
77 {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
78 if ({{# def.$dataNotType:'number' }}
79 ( {{=$schemaValue}} === undefined
80 || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
81 ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
82 : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
83 || {{=$data}} !== {{=$data}}) {
86 if ($exclIsNumber && $schema === undefined) {
87 {{# def.setExclusiveLimit }}
88 $schemaValue = $schemaExcl;
92 $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
94 if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
95 {{# def.setExclusiveLimit }}
103 var $opExpr = '\'' + $opStr + '\''; /*used in error*/
106 if ({{# def.$dataNotType:'number' }}
107 {{=$data}} {{=$notOp}} {{=$schemaValue}}
108 || {{=$data}} !== {{=$data}}) {
111 {{ $errorKeyword = $errorKeyword || $keyword; }}
112 {{# def.error:'_limit' }}
113 } {{? $breakOnError }} else { {{?}}