@qrvey/formula-lang
Version:
QFormula support for qrvey projects
21 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAValidPower = void 0;
const constants_1 = require("../constants");
const getNumericValueFromArgument_1 = require("./getNumericValueFromArgument");
const greaterThanOrEqualToReference_1 = require("./greaterThanOrEqualToReference");
function isAValidPower(param, dataType, context) {
const first_argument = context.fnNode.arguments[0];
const validArgumentTypes = [constants_1.AST_TYPES.unaryExpression, constants_1.AST_TYPES.literal];
const isNotAValidArgumentType = !validArgumentTypes.includes(first_argument.type);
if (isNotAValidArgumentType)
return { valid: true };
const number_1 = (0, getNumericValueFromArgument_1.getNumericValueFromArgument)(first_argument.value, first_argument);
if (typeof number_1 !== 'number')
return { valid: true };
if (number_1 == 0)
return (0, greaterThanOrEqualToReference_1.greaterThanOrEqualToReference)(0)(param, dataType, context);
return { valid: true };
}
exports.isAValidPower = isAValidPower;
//# sourceMappingURL=isAValidPower.js.map