UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

32 lines (31 loc) 1.47 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 { IfcDateTimeValue } from "../../../value/IfcDateTimeValue.js"; import { FuncArgBase } from "./FuncArgBase.js"; export class FuncArgIfcDateTimeString 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; } const result = val.result; if (result instanceof StringValue) { const stringValue = result.getValue(); if (!IfcDateTimeValue.isValidStringRepresentation(stringValue)) { return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} is an IfcDateTime of the form 'YYYY-MM-DDTHH:MM:SS.sss...', ` + `a leading + or - and a trailing time zone specification are allowed.` + `The provided value, '${stringValue}' is not allowed. `, callingExpr.getTextSpan()); } return val; } } } //# sourceMappingURL=FuncArgIfcDateTimeString.js.map