Adding Validation rules to a Spotlight allows the field to accept only the specified form of input, which helps to avoid common user errors. Apty performs validations on specified fields keeping your application data accurate.
This article covers the following sections:
- types of Validators,
- adding a Validator,
- making Validation rules accessible to the end users, and
- deleting Validators.
Types of Validations:
Required Field:
This rule checks whether the field is empty and if so, the form with the input will not be submitted and the error with will be shown to the end user.
Length Constraint:
Checks whether the input fits within the range of the specified length. If the length of the user input is not within the range specified in the validation rule, the input will not be submitted and the error with will be shown to the end user.
Regular Expression:
Powerful way to check the format / accuracy of the input provided by the end user. For example, to check whether the user has entered a valid email address, the following regular expression is used:
^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$
|
Custom Validator:
A template of a JavaScript function with two arguments (field, context) that provides a room for defining specific validation rules for checking the format of user input into the the element under spotlight.

To add a Validator:
To add a single or multiple Validation rules to the user input field, follow the steps below.
1. Login to the Apty Studio using valid credentials. Click on Validations.
2. Create a frame and add a spotlight. Alternatively, click on the previously created frame and select the spotlight in it.
3. In the Validators section click + Add Validator and select the type of Validator that to be added.

4. Select the type of a validator to be added:
Required Field:
If this Validator is selected, the user is required to enter data. If the field is empty, a system provides automatic error message: "This field is required".

Length Constraint:
If length constraint is selected, specify the conditions for the length of the input that must be entered in the field. You can define lower limit, upper limit or both when defining expected input length.

Regular Expression:
If the Regular Expression Validator type is selected, A regular expression that specifies the format of acceptable input must be given in the space opened. The specified regex gets applied to the spotlight. Additionally, provide an error message to be displayed if the format of input does not correspond to the form specified in the regular expression.

Custom Validator:
If the input format to be accepted by the spotlight involves more number of conditions or dependencies with the other fields, then Custom Validator can be chosen. Custom Validator provides a way to write custom JavaScript to validate the input.

To make Validators accessible to end users:
When all the Validations are added to the required Spotlights in a Frame and are ready to be used, system still preserves the Frame in the Draft status, unless stated otherwise.
Yellow dots indicate the frame is in draft mode and blue dots indicate the frames are ready to be published.
To delete a Validator:


Comments
0 comments
Please sign in to leave a comment.