Checkif (attribute of property)
From JRapid
checkif is an attribute of property.
Contents |
Description
The checkif determines whether to mark a property as invalid and throw a validation error when submitting a form or not. It allows the checking of more complex conditions using FPath expressions.
The value for the checkif attribute is an FPath expression returning true/false.
This condition can be used in conjunction with the checkifmessage attribute to specify a custom error message.
Usage
<property ... checkif="FPATH_CONDITION" checkifmessage="MESSAGE" ... />
Example
Checking of a simple condition can be done through the use of checkif. This example checks if the number of people for a reservation are at least 5.
<entity label="Reservation" name="Reservation">
<property display="primary" label="Name" name="name"/>
<property label="Number of people" name="numberOfPeople" type="integer" checkif="numberOfPeople >= 5" />
</entity>
The field on the form is marked as invalid and when the user tries to submit the form an alert showing a general error message is shown.
Using the checkifmessage attribute developers may change the error message to a custom one. The next example adds the custom message to the previous one.
<entity label="Reservation" name="Reservation">
<property display="primary" label="Name" name="name"/>
<property label="Number of people" name="numberOfPeople" type="integer"
checkif="numberOfPeople >= 5" checkifmessage="Number of people must be at least 5" />
</entity>
