Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.missing }}
  4. {{# def.setupKeyword }}
  5. {{# def.$data }}
  6. {{ var $vSchema = 'schema' + $lvl; }}
  7. {{## def.setupLoop:
  8. {{? !$isData }}
  9. var {{=$vSchema}} = validate.schema{{=$schemaPath}};
  10. {{?}}
  11. {{
  12. var $i = 'i' + $lvl
  13. , $propertyPath = 'schema' + $lvl + '[' + $i + ']'
  14. , $missingProperty = '\' + ' + $propertyPath + ' + \'';
  15. if (it.opts._errorDataPathProperty) {
  16. it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
  17. }
  18. }}
  19. #}}
  20. {{## def.isRequiredOwnProperty:
  21. Object.prototype.hasOwnProperty.call({{=$data}}, {{=$vSchema}}[{{=$i}}])
  22. #}}
  23. {{? !$isData }}
  24. {{? $schema.length < it.opts.loopRequired &&
  25. it.schema.properties && Object.keys(it.schema.properties).length }}
  26. {{ var $required = []; }}
  27. {{~ $schema:$property }}
  28. {{ var $propertySch = it.schema.properties[$property]; }}
  29. {{? !($propertySch && {{# def.nonEmptySchema:$propertySch}}) }}
  30. {{ $required[$required.length] = $property; }}
  31. {{?}}
  32. {{~}}
  33. {{??}}
  34. {{ var $required = $schema; }}
  35. {{?}}
  36. {{?}}
  37. {{? $isData || $required.length }}
  38. {{
  39. var $currentErrorPath = it.errorPath
  40. , $loopRequired = $isData || $required.length >= it.opts.loopRequired
  41. , $ownProperties = it.opts.ownProperties;
  42. }}
  43. {{? $breakOnError }}
  44. var missing{{=$lvl}};
  45. {{? $loopRequired }}
  46. {{# def.setupLoop }}
  47. var {{=$valid}} = true;
  48. {{?$isData}}{{# def.check$dataIsArray }}{{?}}
  49. for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
  50. {{=$valid}} = {{=$data}}[{{=$vSchema}}[{{=$i}}]] !== undefined
  51. {{? $ownProperties }}
  52. && {{# def.isRequiredOwnProperty }}
  53. {{?}};
  54. if (!{{=$valid}}) break;
  55. }
  56. {{? $isData }} } {{?}}
  57. {{# def.checkError:'required' }}
  58. else {
  59. {{??}}
  60. if ({{# def.checkMissingProperty:$required }}) {
  61. {{# def.errorMissingProperty:'required' }}
  62. } else {
  63. {{?}}
  64. {{??}}
  65. {{? $loopRequired }}
  66. {{# def.setupLoop }}
  67. {{? $isData }}
  68. if ({{=$vSchema}} && !Array.isArray({{=$vSchema}})) {
  69. {{# def.addError:'required' }}
  70. } else if ({{=$vSchema}} !== undefined) {
  71. {{?}}
  72. for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
  73. if ({{=$data}}[{{=$vSchema}}[{{=$i}}]] === undefined
  74. {{? $ownProperties }}
  75. || !{{# def.isRequiredOwnProperty }}
  76. {{?}}) {
  77. {{# def.addError:'required' }}
  78. }
  79. }
  80. {{? $isData }} } {{?}}
  81. {{??}}
  82. {{~ $required:$propertyKey }}
  83. {{# def.allErrorsMissingProperty:'required' }}
  84. {{~}}
  85. {{?}}
  86. {{?}}
  87. {{ it.errorPath = $currentErrorPath; }}
  88. {{?? $breakOnError }}
  89. if (true) {
  90. {{?}}