oneOf.jst 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.setupNextLevel }}
  5. var {{=$errs}} = errors;
  6. var prevValid{{=$lvl}} = false;
  7. var {{=$valid}} = false;
  8. {{ var $currentBaseId = $it.baseId; }}
  9. {{# def.setCompositeRule }}
  10. {{~ $schema:$sch:$i }}
  11. {{? {{# def.nonEmptySchema:$sch }} }}
  12. {{
  13. $it.schema = $sch;
  14. $it.schemaPath = $schemaPath + '[' + $i + ']';
  15. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  16. }}
  17. {{# def.insertSubschemaCode }}
  18. {{??}}
  19. var {{=$nextValid}} = true;
  20. {{?}}
  21. {{? $i }}
  22. if ({{=$nextValid}} && prevValid{{=$lvl}})
  23. {{=$valid}} = false;
  24. else {
  25. {{ $closingBraces += '}'; }}
  26. {{?}}
  27. if ({{=$nextValid}}) {{=$valid}} = prevValid{{=$lvl}} = true;
  28. {{~}}
  29. {{# def.resetCompositeRule }}
  30. {{= $closingBraces }}
  31. if (!{{=$valid}}) {
  32. {{# def.extraError:'oneOf' }}
  33. } else {
  34. {{# def.resetErrors }}
  35. {{? it.opts.allErrors }} } {{?}}