UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

21 lines 995 B
import { ERROR_LIST, ERROR_DICTIONARY } from '../errors/dictionary'; import { AST_PRIMITIVES, AST_TYPES, CUSTOM_PRIMITIVE, } from '../constants'; import { getNumberFromLiteral } from './getNumericValueFromArgument'; export function isInteger(param, _dataType, context) { const isLiteral = context.argument.type === AST_TYPES.literal; if (!isLiteral) return { valid: true }; const numberValue = 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), ERROR_DICTIONARY[ERROR_LIST.integerNumber]), { mismatchData: { primitive: AST_PRIMITIVES.NUMBER, customPrimitive: CUSTOM_PRIMITIVE.INTEGER, customReceived: CUSTOM_PRIMITIVE.DECIMAL, } }); return baseResponse; } //# sourceMappingURL=isInteger.js.map