Skip to main content

Validations in Collection

Allows you to apply different validation rules on collection fields to ensure that only valid data gets saved in a collection.


1. Accessing Validations

To access Validations settings, go to the Collection panel in the Left Toolbar of the builder and open the settings of the collection in whose fields you want to add validations. A dialogue box containing all setting options to modify the collection will open. Click on "Validations" once and the validations settings will open.

DrapCode Builder Collection Validations

2. Types of Validation Rules

  • Required: Allows you to make a field mandatory or compulsory to be filled for further actions.
  • Minimum: Allows you to set a minimum limit on the numeric value as well as on the number of characters.
  • Maximum: Allows you to set a maximum limit on the numeric value as well as on the number of characters.
  • Pattern: Allows you to restrict entries in a column field to the set characters or number pattern only. No other entry will be supported.
  • Step: Allows you to restrict data entry in a number field to only multiples of the number that you've mentioned as a value. For example, if the value given is 2, then the accepted numbers will be 2, 4, 6 and so on. Remember, it applies only to number fields.
  • Unique: Ensures that all entries in a field are different from each other.
  • Email: Allows you to restrict a column entry to email format only. No other input format will be supported.
  • URL: Allows you to restrict a column entry to URL format only, for example, https://drapcode.com. No other input format will be supported.

3. Creating a Validation

To create a validation for a collection field, open the Validations settings of a collection. Add the validation name, select the collection field and apply a validation rule to it.

Note: Click the Save icon before clicking the Save button to successfully create a validation.

DrapCode Builder Collection Validations

4. Binding Validations

After adding validations, refresh the builder and go to the page containing a collection form and bind the same collection to it in which you have added validations. Also bind a Save Collection event on it. In the example below, the collection and event are already bound in the collection form.

Now, open the collection form settings, go to the Validations field and bind the created validation with the form. You can open the page in the publish or preview mode to see how the validations work.

In the example below, the Required validation rule is applied on the "Contact Number" field and to check the applied validation, the Contact Number field is left empty.

DrapCode Builder Collection Validations