range_with_errors.jst 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {{
  2. var $data = 'data' + (it.dataLevel || '')
  3. , $min = it.schema['x-range'][0]
  4. , $max = it.schema['x-range'][1]
  5. , $exclusive = !!it.schema.exclusiveRange
  6. , $gt = $exclusive ? '>' : '>='
  7. , $lt = $exclusive ? '<' : '<='
  8. , $lvl = it.level
  9. , $err = 'err' + $lvl;
  10. }}
  11. var minOk{{=$lvl}} = {{=$data}} {{=$gt}} {{=$min}};
  12. var valid{{=$lvl}} = minOk{{=$lvl}} && {{=$data}} {{=$lt}} {{=$max}};
  13. if (!valid{{=$lvl}}) {
  14. var {{=$err}};
  15. if (minOk{{=$lvl}}) {
  16. {{=$err}} = {
  17. keyword: 'x-range',
  18. message: 'should be {{=$lt}} {{=$max}}',
  19. params: {
  20. comparison: '{{=$lt}}',
  21. limit: {{=$max}},
  22. exclusive: {{=$exclusive}}
  23. }
  24. };
  25. } else {
  26. {{=$err}} = {
  27. keyword: 'x-range',
  28. message: 'should be {{=$gt}} {{=$min}}',
  29. params: {
  30. comparison: '{{=$gt}}',
  31. limit: {{=$min}},
  32. exclusive: {{=$exclusive}}
  33. }
  34. };
  35. }
  36. errors++;
  37. if (vErrors) vErrors[vErrors.length] = {{=$err}};
  38. else vErrors = [{{=$err}}];
  39. }