oneOf.jst 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 }} } {{?}}