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.

55 lines
1.2 KiB

4 years ago
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.setupNextLevel }}
  5. {{
  6. var $idx = 'i' + $lvl
  7. , $dataNxt = $it.dataLevel = it.dataLevel + 1
  8. , $nextData = 'data' + $dataNxt
  9. , $currentBaseId = it.baseId
  10. , $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
  11. }}
  12. var {{=$errs}} = errors;
  13. var {{=$valid}};
  14. {{? $nonEmptySchema }}
  15. {{# def.setCompositeRule }}
  16. {{
  17. $it.schema = $schema;
  18. $it.schemaPath = $schemaPath;
  19. $it.errSchemaPath = $errSchemaPath;
  20. }}
  21. var {{=$nextValid}} = false;
  22. for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
  23. {{
  24. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  25. var $passData = $data + '[' + $idx + ']';
  26. $it.dataPathArr[$dataNxt] = $idx;
  27. }}
  28. {{# def.generateSubschemaCode }}
  29. {{# def.optimizeValidate }}
  30. if ({{=$nextValid}}) break;
  31. }
  32. {{# def.resetCompositeRule }}
  33. {{= $closingBraces }}
  34. if (!{{=$nextValid}}) {
  35. {{??}}
  36. if ({{=$data}}.length == 0) {
  37. {{?}}
  38. {{# def.error:'contains' }}
  39. } else {
  40. {{? $nonEmptySchema }}
  41. {{# def.resetErrors }}
  42. {{?}}
  43. {{? it.opts.allErrors }} } {{?}}