Validation Rules

Struct types can have validation rules. Let's define StudentReport again and put the validation rules in the struct.

<less thanx < 35int, long, number, string, date
<=less than or equalsx <= 35"”
>greater thanx > 35"”
>=greater than or equalsx >= 35"”
==equalsx == 35"”
!=not equalsx != 35"”
containsnot equalsname.contains(‘ony’)string
maxlenmaximum lengthname.maxlen(32)string

New validation rules can be added by writing Java classes.

Rule Functions

There are some functions that can be used in a rule.

len()lengthname.len() < 64string
year()yearorderDate.year() > 2015date
month()monthorderDate.month() > 3date
day()day (day of month) > 25date
hour()hourorderDate.hour() > 5date
minute()minuteorderDate.minute() > 30date
second()secondorderDate.second() > 3date
date()dateorderDate > date(‘2019’)date