The validate() method is a standard method on the field of the form data source. This method is called when a value is entered in a specific field, and it's overridden if extra field validation is needed.
Example
You have a custom form with a table named TrainingMaster. The table has a field named Participants, where entering a number higher than 20 isn't allowed.
The coding pattern can be as follows:
[DataSource] class TrainingMaster { [DataField] class Participants { public boolean validate() { boolean ret; ret = super() && (TrainingMaster.Participants <= 20); return ret; } } }
Make sure that you offer a reason for errors that are thrown, as shown in the following code example:
[DataSource] class TrainingMaster { [DataField] class Participants { public boolean validate() { boolean ret; if (TrainingMaster.Participants > 20) { throw error("Maximum 20 participants"); return false; } ret = super(); return ret; } } }
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.