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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.setupNextLevel }}
  5. {{## def.validateItems:startFrom:
  6. for (var {{=$idx}} = {{=startFrom}}; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
  7. {{
  8. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  9. var $passData = $data + '[' + $idx + ']';
  10. $it.dataPathArr[$dataNxt] = $idx;
  11. }}
  12. {{# def.generateSubschemaCode }}
  13. {{# def.optimizeValidate }}
  14. {{? $breakOnError }}
  15. if (!{{=$nextValid}}) break;
  16. {{?}}
  17. }
  18. #}}
  19. {{
  20. var $idx = 'i' + $lvl
  21. , $dataNxt = $it.dataLevel = it.dataLevel + 1
  22. , $nextData = 'data' + $dataNxt
  23. , $currentBaseId = it.baseId;
  24. }}
  25. var {{=$errs}} = errors;
  26. var {{=$valid}};
  27. {{? Array.isArray($schema) }}
  28. {{ /* 'items' is an array of schemas */}}
  29. {{ var $additionalItems = it.schema.additionalItems; }}
  30. {{? $additionalItems === false }}
  31. {{=$valid}} = {{=$data}}.length <= {{= $schema.length }};
  32. {{
  33. var $currErrSchemaPath = $errSchemaPath;
  34. $errSchemaPath = it.errSchemaPath + '/additionalItems';
  35. }}
  36. {{# def.checkError:'additionalItems' }}
  37. {{ $errSchemaPath = $currErrSchemaPath; }}
  38. {{# def.elseIfValid}}
  39. {{?}}
  40. {{~ $schema:$sch:$i }}
  41. {{? {{# def.nonEmptySchema:$sch }} }}
  42. {{=$nextValid}} = true;
  43. if ({{=$data}}.length > {{=$i}}) {
  44. {{
  45. var $passData = $data + '[' + $i + ']';
  46. $it.schema = $sch;
  47. $it.schemaPath = $schemaPath + '[' + $i + ']';
  48. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  49. $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
  50. $it.dataPathArr[$dataNxt] = $i;
  51. }}
  52. {{# def.generateSubschemaCode }}
  53. {{# def.optimizeValidate }}
  54. }
  55. {{# def.ifResultValid }}
  56. {{?}}
  57. {{~}}
  58. {{? typeof $additionalItems == 'object' && {{# def.nonEmptySchema:$additionalItems }} }}
  59. {{
  60. $it.schema = $additionalItems;
  61. $it.schemaPath = it.schemaPath + '.additionalItems';
  62. $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
  63. }}
  64. {{=$nextValid}} = true;
  65. if ({{=$data}}.length > {{= $schema.length }}) {
  66. {{# def.validateItems: $schema.length }}
  67. }
  68. {{# def.ifResultValid }}
  69. {{?}}
  70. {{?? {{# def.nonEmptySchema:$schema }} }}
  71. {{ /* 'items' is a single schema */}}
  72. {{
  73. $it.schema = $schema;
  74. $it.schemaPath = $schemaPath;
  75. $it.errSchemaPath = $errSchemaPath;
  76. }}
  77. {{# def.validateItems: 0 }}
  78. {{?}}
  79. {{? $breakOnError }}
  80. {{= $closingBraces }}
  81. if ({{=$errs}} == errors) {
  82. {{?}}