Adding a Validator

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 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:

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. Validations can be edited only while the frame is in Draft Mode.

To delete a Validator:

To delete a Validation rule, hover over the Validator. The  (Delete Validator) icon is going to be displayed at the top right corner of the Validator button.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.