UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

31 lines (30 loc) 1.4 kB
import { StringValue } from "../../../value/StringValue.js"; import { ExprEvalTypeErrorObj, isExprEvalError, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { Type, Types } from "../../../type/Types.js"; import { IfcDateValue } from "../../../value/IfcDateValue.js"; import { FuncArgBase } from "./FuncArgBase.js"; export class FuncArgIfcDateString extends FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Types.or(Type.STRING); } transformForTypeCheck(callingExpr, invocationValue) { const val = super.transformForTypeCheck(callingExpr, invocationValue); if (isExprEvalError(val)) { return val; } if (val.result instanceof StringValue) { const stringValue = val.result.getValue(); if (!IfcDateValue.isValidStringRepresentation(stringValue)) { return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} is an IfcDate of the form 'YYYY-MM-DD', optionally with` + `leading + or -, and trailing time zone specification.` + `The provided value, '${stringValue}' is not allowed.`, callingExpr.getTextSpan()); } return val; } } } //# sourceMappingURL=FuncArgIfcDateString.js.map