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.

79 lines
1.8 KiB

  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.missing }}
  4. {{# def.setupKeyword }}
  5. {{# def.setupNextLevel }}
  6. {{## def.propertyInData:
  7. {{=$data}}{{= it.util.getProperty($property) }} !== undefined
  8. {{? $ownProperties }}
  9. && Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($property)}}')
  10. {{?}}
  11. #}}
  12. {{
  13. var $schemaDeps = {}
  14. , $propertyDeps = {}
  15. , $ownProperties = it.opts.ownProperties;
  16. for ($property in $schema) {
  17. if ($property == '__proto__') continue;
  18. var $sch = $schema[$property];
  19. var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
  20. $deps[$property] = $sch;
  21. }
  22. }}
  23. var {{=$errs}} = errors;
  24. {{ var $currentErrorPath = it.errorPath; }}
  25. var missing{{=$lvl}};
  26. {{ for (var $property in $propertyDeps) { }}
  27. {{ $deps = $propertyDeps[$property]; }}
  28. {{? $deps.length }}
  29. if ({{# def.propertyInData }}
  30. {{? $breakOnError }}
  31. && ({{# def.checkMissingProperty:$deps }})) {
  32. {{# def.errorMissingProperty:'dependencies' }}
  33. {{??}}
  34. ) {
  35. {{~ $deps:$propertyKey }}
  36. {{# def.allErrorsMissingProperty:'dependencies' }}
  37. {{~}}
  38. {{?}}
  39. } {{# def.elseIfValid }}
  40. {{?}}
  41. {{ } }}
  42. {{
  43. it.errorPath = $currentErrorPath;
  44. var $currentBaseId = $it.baseId;
  45. }}
  46. {{ for (var $property in $schemaDeps) { }}
  47. {{ var $sch = $schemaDeps[$property]; }}
  48. {{? {{# def.nonEmptySchema:$sch }} }}
  49. {{=$nextValid}} = true;
  50. if ({{# def.propertyInData }}) {
  51. {{
  52. $it.schema = $sch;
  53. $it.schemaPath = $schemaPath + it.util.getProperty($property);
  54. $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
  55. }}
  56. {{# def.insertSubschemaCode }}
  57. }
  58. {{# def.ifResultValid }}
  59. {{?}}
  60. {{ } }}
  61. {{? $breakOnError }}
  62. {{= $closingBraces }}
  63. if ({{=$errs}} == errors) {
  64. {{?}}