Validation
We almost always have to validate string data, such as username, email etc. So why not just incorporate the data validation into our data models and generate the code that already knows how to validate data?
OneGen supports validation of string
and string?
data types. The validation
is based on regular expressions.
Validation example
- Select or create a class
- Select or create a property with
string
orstring?
data type - Click on the validation icon next to the data type field
- Enter a simple validation regex (allowing only alphanumeric characters):
[a-zA-Z0-9]+
- Enter a message for the user in case validation fails: Only alphanumeric characters are allowed!