Functions

A Validation Expression may use Functions. We define as a function with parameters. The following functions are defined:

Function Parameters Return Value Comment
BOOL BOOLEAN or CHAR BOOLEAN Type conversion, supportted values (0, 1, no, yes, true, false)
CHAR Exp or TYPEOF(Exp) CHAR TYPEOF(Exp) may not be float
CHARF FLOAT,and INT CHAR Converts a Float number, where 2nd parameter specifies how many decimal digits MUST appear after the point.
TIME TIME or CHAR TIME Type Conversion to time
DATE TIME or CHAR TIME Type conversion to date
INT INT,FLOAT,BOOL,CHAR INT Type conversion to integer
FLOAT INT,FLOAT,BOOL,or CHAR FLOAT Type conversion to float
SUBSTR CHAR,INT,and INT CHAR The SUBSTR function returns a substring of its first parameter. Second parameter is a starting position of the substring, third parameter is the ending position of the substring. Positions are 1-based.
STRLEN CHAR INT The STRLEN function returns the length if its parameter.
LOWER CHAR CHAR The LOWER function returns its parameter lower-cased.
UPPER CHAR CHAR The UPPER function returns its parameter upper-cased.
IIF BOOLEAN,Exp,and Exp TYPEOF(Exp) The IIF function returns the value of its second parameter if the first parameter evaluates to true, or the value of its third parameter otherwise. Types of second and third parameter must be same, and it is the type of the result. These parameters are also known as CondExp, TrueExp, and FalseExp, respectively.
YEAR TIME INT Returns four digit year as integer.
MONTH TIME INT Returns month as interger value in range 1 to 12
DAY TIME INT Returns day of month as integer in range 1 o 31
WEEKDAY TIME INT Returns day of week as integer, see notes below.
TYPEOF Exp CHAR The input parameter, Exp, can be any valid expression in the grammar. This function will return a CHAR representation of the given expression's type, one of: {BOOLEAN, CHAR, FLOAT, INT, TIME}
MATCH CHAR,and Exp BOOLEAN Takes a Regular Expression regex as a CHAR and an expression Exp, and returns True if expression matches regex and False otherwise.

Notes:

  • The BOOL, CHAR, TIME, DATE, INT and FLOAT functions are used just to change a type of expression. The DATE and TIME functions are synonyms. Note that any of these functions may fail (return an ERROR value) if the parameter can not be transformed to the appropriate type.
  • In conversion from BOOLEAN to INT or FLOAT, .TRUE. is converted to 1 and .FALSE. is converted to 0. Casting FLOAT to INTEGER discards the fractional part.
  • When converting to CHAR, BOOL values are represented as “0” and “1”, TIME values are represented using format defined in RFC 1123 with digital timezone, INT values are represented with no leading zeros.
  • When converting from CHAR to BOOL, values “0”,”1”,”YES”,”NO”,”TRUE” and “FALSE” (no matter what the case) MUST be understood.
  • When converting from CHAR to TIME, any RFC 1123 –compliant format MUST be understood. A leading and/or trailing # MUST be removed before conversion.
  • When converting from CHAR to INT or FLOAT, usual formats MUST be understood. Scientific format (with exponent) MUST NOT be understood. FLOAT numbers with empty integral part ( .5, -.4) MUST be understood as long as there is at least one digit after the decimal point.
  • The YEAR, MONTH, DAY and WEEKDAY parse the date part of TIME value. They return values ranging from 1 to the appropriate maximum. WEEKDAY returns 1 for Sunday, 2 for Monday etc.
  • Other functions may be defined later (HOUR and MINUTE are first candidates). If a server uses a function the client does not recognize, the client MUST evaluate it as ERROR.
  • A Validation Expression may have Operations applied to the parameters. The Operators may be applied on certain types that determine the result type. The input types and resulting output type is defined in the Validation Expression List of Operators Table (below).