multipleOf.jst 644 B

12345678910111213141516171819202122
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.$data }}
  5. {{# def.numberKeyword }}
  6. var division{{=$lvl}};
  7. if ({{?$isData}}
  8. {{=$schemaValue}} !== undefined && (
  9. typeof {{=$schemaValue}} != 'number' ||
  10. {{?}}
  11. (division{{=$lvl}} = {{=$data}} / {{=$schemaValue}},
  12. {{? it.opts.multipleOfPrecision }}
  13. Math.abs(Math.round(division{{=$lvl}}) - division{{=$lvl}}) > 1e-{{=it.opts.multipleOfPrecision}}
  14. {{??}}
  15. division{{=$lvl}} !== parseInt(division{{=$lvl}})
  16. {{?}}
  17. )
  18. {{?$isData}} ) {{?}} ) {
  19. {{# def.error:'multipleOf' }}
  20. } {{? $breakOnError }} else { {{?}}