Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_limit.jst 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.$data }}
  5. {{## def.setExclusiveLimit:
  6. $exclusive = true;
  7. $errorKeyword = $exclusiveKeyword;
  8. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  9. #}}
  10. {{
  11. var $isMax = $keyword == 'maximum'
  12. , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
  13. , $schemaExcl = it.schema[$exclusiveKeyword]
  14. , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
  15. , $op = $isMax ? '<' : '>'
  16. , $notOp = $isMax ? '>' : '<'
  17. , $errorKeyword = undefined;
  18. }}
  19. {{? $isDataExcl }}
  20. {{
  21. var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
  22. , $exclusive = 'exclusive' + $lvl
  23. , $exclType = 'exclType' + $lvl
  24. , $exclIsNumber = 'exclIsNumber' + $lvl
  25. , $opExpr = 'op' + $lvl
  26. , $opStr = '\' + ' + $opExpr + ' + \'';
  27. }}
  28. var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
  29. {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
  30. var {{=$exclusive}};
  31. var {{=$exclType}} = typeof {{=$schemaValueExcl}};
  32. if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
  33. {{ var $errorKeyword = $exclusiveKeyword; }}
  34. {{# def.error:'_exclusiveLimit' }}
  35. } else if ({{# def.$dataNotType:'number' }}
  36. {{=$exclType}} == 'number'
  37. ? (
  38. ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
  39. ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
  40. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  41. )
  42. : (
  43. ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
  44. ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
  45. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  46. )
  47. || {{=$data}} !== {{=$data}}) {
  48. var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
  49. {{
  50. if ($schema === undefined) {
  51. $errorKeyword = $exclusiveKeyword;
  52. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  53. $schemaValue = $schemaValueExcl;
  54. $isData = $isDataExcl;
  55. }
  56. }}
  57. {{??}}
  58. {{
  59. var $exclIsNumber = typeof $schemaExcl == 'number'
  60. , $opStr = $op; /*used in error*/
  61. }}
  62. {{? $exclIsNumber && $isData }}
  63. {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
  64. if ({{# def.$dataNotType:'number' }}
  65. ( {{=$schemaValue}} === undefined
  66. || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
  67. ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
  68. : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
  69. || {{=$data}} !== {{=$data}}) {
  70. {{??}}
  71. {{
  72. if ($exclIsNumber && $schema === undefined) {
  73. {{# def.setExclusiveLimit }}
  74. $schemaValue = $schemaExcl;
  75. $notOp += '=';
  76. } else {
  77. if ($exclIsNumber)
  78. $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
  79. if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
  80. {{# def.setExclusiveLimit }}
  81. $notOp += '=';
  82. } else {
  83. $exclusive = false;
  84. $opStr += '=';
  85. }
  86. }
  87. var $opExpr = '\'' + $opStr + '\''; /*used in error*/
  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 { {{?}}