source: trip-planner-front/node_modules/ajv/dist/vocabularies/validation/multipleOf.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 998 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const codegen_1 = require("../../compile/codegen");
4const error = {
5 message: ({ schemaCode }) => codegen_1.str `must be multiple of ${schemaCode}`,
6 params: ({ schemaCode }) => codegen_1._ `{multipleOf: ${schemaCode}}`,
7};
8const def = {
9 keyword: "multipleOf",
10 type: "number",
11 schemaType: "number",
12 $data: true,
13 error,
14 code(cxt) {
15 const { gen, data, schemaCode, it } = cxt;
16 // const bdt = bad$DataType(schemaCode, <string>def.schemaType, $data)
17 const prec = it.opts.multipleOfPrecision;
18 const res = gen.let("res");
19 const invalid = prec
20 ? codegen_1._ `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
21 : codegen_1._ `${res} !== parseInt(${res})`;
22 cxt.fail$data(codegen_1._ `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
23 },
24};
25exports.default = def;
26//# sourceMappingURL=multipleOf.js.map
Note: See TracBrowser for help on using the repository browser.