Skip to content

Validation

Overview

The Validation enables you to specify various validation rules for input fields directly within Aliveforms. By setting the validate custom property on your screen, you can enforce rules such as length constraints, value ranges, and presence checks, among others. This plugin helps maintain data quality and provides immediate feedback to users when their input does not meet the defined criteria.

Custom Properties

  • validate:
  • Define the validation rules as a string. Each rule should be specified on a new line using the format key=value. The available keys include:
    • max_length: Maximum allowed length of the input.
    • min_length: Minimum required length of the input.
    • length_range: Specifies a range for the length of the input (format: min,max).
    • max_value: Maximum numeric value allowed.
    • min_value: Minimum numeric value allowed.
    • value_range: Specifies a numeric range for the input value (format: min,max).
    • contains: Input must contain this substring.
    • not_contains: Input must not contain this substring.
    • starts_with: Input must start with this substring.
    • ends_with: Input must end with this substring.
    • in_list: Input must be one of the specified values (comma-separated).
    • not_in_list: Input must not be one of the specified values (comma-separated).
    • date_range: Specifies a range for valid dates (format: start_date,end_date).
    • time_range: Specifies a range for valid times (format: start_time,end_time).
    • max_items: Maximum number of items allowed in a list or array.
    • min_items: Minimum number of items required in a list or array.

Example

To apply validation rules, add the following custom property to your input element:

key: validate value:

max_length=10
min_length=1
value_range=1,100
contains=abc

In this example: - The input must have a maximum length of 10 characters. - The input must have a minimum length of 1 character. - The input value must be between 1 and 100. - The input must contain the substring "abc".

Benefits

  • Data Integrity: Ensure that user inputs meet the required criteria before submission.
  • User Feedback: Provide immediate feedback to users, helping them correct errors in their input.
  • Flexibility: Easily define various validation rules to suit the specific needs of your forms.

Notes

  • Ensure that the validate property is properly formatted to avoid errors in validation.
  • This plugin can be combined with other Aliveforms features for enhanced form functionality.