UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

25 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isInteger = void 0; const dictionary_1 = require("../errors/dictionary"); const constants_1 = require("../constants"); const getNumericValueFromArgument_1 = require("./getNumericValueFromArgument"); function isInteger(param, _dataType, context) { const isLiteral = context.argument.type === constants_1.AST_TYPES.literal; if (!isLiteral) return { valid: true }; const numberValue = (0, getNumericValueFromArgument_1.getNumberFromLiteral)(String(param), context.argument); const valid = numberValue !== null && Number.isInteger(numberValue); const baseResponse = { valid, }; if (!valid) return Object.assign(Object.assign(Object.assign({}, baseResponse), dictionary_1.ERROR_DICTIONARY[dictionary_1.ERROR_LIST.integerNumber]), { mismatchData: { primitive: constants_1.AST_PRIMITIVES.NUMBER, customPrimitive: constants_1.CUSTOM_PRIMITIVE.INTEGER, customReceived: constants_1.CUSTOM_PRIMITIVE.DECIMAL, } }); return baseResponse; } exports.isInteger = isInteger; //# sourceMappingURL=isInteger.js.map