Custom Validation in Mendix
This article describes one way to implement custom data validation on the Mendix platform. If you find the subject of data validation interesting, give this article a try. It is a rather long read, but I hope it will be of value to you.
Selection criteria
Before jumping to implement your own validation, consider tools already available on the Mendix platform: validation rules.
One thing to keep in mind is that scope of a Mendix validation rule is a single attribute of an entity. If your business domain requires rules that span a combination of attributes, associations and entities, then consider alternatives such as this one.
The described approach also meets the following criteria:
- validation results require little administration
- basic validations can be combined to fit specific needs
- single source of business logic
- easily invocable throughout application
- usable in UI and in background processes
- support for multiple languages
The next two sections describe a basic framework and a validation template. Then all the theory is put into practice.
Validation framework
This is a generic entity that is common for all applications of validation.