Newer
Older
CVSS_3.0_GUI / node_modules / nwjs-builder-phoenix / node_modules / request / node_modules / har-validator / node_modules / ajv / lib / dot / _limit.jst
root on 7 May 2019 3 KB Initial commit
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.$data }}
  5.  
  6. {{## def.setExclusiveLimit:
  7. $exclusive = true;
  8. $errorKeyword = $exclusiveKeyword;
  9. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  10. #}}
  11.  
  12. {{
  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;
  20. }}
  21.  
  22. {{? $isDataExcl }}
  23. {{
  24. var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
  25. , $exclusive = 'exclusive' + $lvl
  26. , $exclType = 'exclType' + $lvl
  27. , $exclIsNumber = 'exclIsNumber' + $lvl
  28. , $opExpr = 'op' + $lvl
  29. , $opStr = '\' + ' + $opExpr + ' + \'';
  30. }}
  31. var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
  32. {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
  33.  
  34. var {{=$exclusive}};
  35. var {{=$exclType}} = typeof {{=$schemaValueExcl}};
  36. if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
  37. {{ var $errorKeyword = $exclusiveKeyword; }}
  38. {{# def.error:'_exclusiveLimit' }}
  39. } else if ({{# def.$dataNotType:'number' }}
  40. {{=$exclType}} == 'number'
  41. ? (
  42. ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
  43. ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
  44. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  45. )
  46. : (
  47. ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
  48. ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
  49. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  50. )
  51. || {{=$data}} !== {{=$data}}) {
  52. var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
  53. {{??}}
  54. {{
  55. var $exclIsNumber = typeof $schemaExcl == 'number'
  56. , $opStr = $op; /*used in error*/
  57. }}
  58.  
  59. {{? $exclIsNumber && $isData }}
  60. {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
  61. if ({{# def.$dataNotType:'number' }}
  62. ( {{=$schemaValue}} === undefined
  63. || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
  64. ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
  65. : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
  66. || {{=$data}} !== {{=$data}}) {
  67. {{??}}
  68. {{
  69. if ($exclIsNumber && $schema === undefined) {
  70. {{# def.setExclusiveLimit }}
  71. $schemaValue = $schemaExcl;
  72. $notOp += '=';
  73. } else {
  74. if ($exclIsNumber)
  75. $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
  76.  
  77. if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
  78. {{# def.setExclusiveLimit }}
  79. $notOp += '=';
  80. } else {
  81. $exclusive = false;
  82. $opStr += '=';
  83. }
  84. }
  85.  
  86. var $opExpr = '\'' + $opStr + '\''; /*used in error*/
  87. }}
  88.  
  89. if ({{# def.$dataNotType:'number' }}
  90. {{=$data}} {{=$notOp}} {{=$schemaValue}}
  91. || {{=$data}} !== {{=$data}}) {
  92. {{?}}
  93. {{?}}
  94. {{ $errorKeyword = $errorKeyword || $keyword; }}
  95. {{# def.error:'_limit' }}
  96. } {{? $breakOnError }} else { {{?}}
Buy Me A Coffee