patternRequired.jst 677 B

12345678910111213141516171819202122232425262728
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{
  5. var $key = 'key' + $lvl
  6. , $matched = 'patternMatched' + $lvl
  7. , $closingBraces = ''
  8. , $ownProperties = it.opts.ownProperties;
  9. }}
  10. var {{=$valid}} = true;
  11. {{~ $schema:$pProperty }}
  12. var {{=$matched}} = false;
  13. for (var {{=$key}} in {{=$data}}) {
  14. {{# def.checkOwnProperty }}
  15. {{=$matched}} = {{= it.usePattern($pProperty) }}.test({{=$key}});
  16. if ({{=$matched}}) break;
  17. }
  18. {{ var $missingPattern = it.util.escapeQuotes($pProperty); }}
  19. if (!{{=$matched}}) {
  20. {{=$valid}} = false;
  21. {{# def.addError:'patternRequired' }}
  22. } {{# def.elseIfValid }}
  23. {{~}}
  24. {{= $closingBraces }}