main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1023 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const codegen_1 = require("../../compile/codegen");
|
---|
| 4 | const error = {
|
---|
| 5 | message: ({ schemaCode }) => (0, codegen_1.str) `must be multiple of ${schemaCode}`,
|
---|
| 6 | params: ({ schemaCode }) => (0, codegen_1._) `{multipleOf: ${schemaCode}}`,
|
---|
| 7 | };
|
---|
| 8 | const 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 | ? (0, codegen_1._) `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
|
---|
| 21 | : (0, codegen_1._) `${res} !== parseInt(${res})`;
|
---|
| 22 | cxt.fail$data((0, codegen_1._) `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
|
---|
| 23 | },
|
---|
| 24 | };
|
---|
| 25 | exports.default = def;
|
---|
| 26 | //# sourceMappingURL=multipleOf.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.