multipleOf.jst 618 B

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