dependencies.jst 1.6 KB

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