Validators

Validators: Create Custom Validation Rules

Introduction

Validators is a new feature that allows you to create custom validation rules for form fields within your target applications. This empowers you to ensure that users enter data in the correct format, improving data quality and streamlining workflows. This document will guide you through creating and using Validators.

What are Validators?

Validators are a new content type within the Userlane Editor. They allow Managers to define rules that specify the format of data that users should enter into form fields. These rules are based on regular expressions (regex), a powerful tool for pattern matching.

Key Features and Benefits:

  • Custom Validation: Create rules tailored to your specific data requirements.

  • Improved Data Quality: Ensure users enter data in the correct format, reducing errors and inconsistencies.

  • Simplified Guidance: Provide users with clear, concise prompts on how to fill out form fields.

  • Enhanced User Experience: Give users immediate feedback on whether their input is valid, helping them correct mistakes in real-time.

  • GenAI Powered: Leverage the power of generative AI to help create regular expressions.

How to Create a Validator

Validators are created simply and quickly in the Userlane Editor:

  1. Create a New Validator: Choose the "Create Validator" option from the Userlane Editor to start the Validator recording mode.

  2. Select a Form Field: In the Validator recording mode, navigate to the form field in your target application that you want to validate and select it with your cursor.

  3. Define the Validation Rule:

  • Use GenAI (Recommended): Describe the desired data format in natural language, and be as precise as possible (e.g., "a 10-digit phone number," "an email address ending in @mycompany.com"). Our platform's AI will generate the corresponding regular expression. You can then review and edit the generated regex.

  • Enter Regular Expression Manually: If you are familiar with regular expressions, you can enter the rule directly.

  1. Write an Input Prompt: Provide a short, helpful message that will be displayed to the user when they focus on the form field. This message should explain the expected data format (e.g., "Enter a valid email address").

  2. Save and Publish: Save your Validator. Once published, the Validator will be active for end-users.


End-User Experience

When a user interacts with a form field that has a Validator applied, they will experience the following:

  1. Input Prompt: When the user focuses on the form field, the text you created will be displayed, providing guidance on the expected input.

  2. Real-time Validation: Once the user moves on from the form field, the Validator checks their input against the defined rule.

  3. Visual Feedback:

  • Valid Input: If the user's input matches the rule, the form field will be framed in green, indicating that the data is valid.

  • Invalid Input: If the user's input does not match the rule, the form field will be framed in red, indicating that the data is invalid. 


Best Practices

  • Keep Input Prompts Clear and Concise: Provide specific instructions in your input prompts to help users understand the expected format.

  • Test Your Validators Thoroughly: Before publishing, test your Validators with various inputs to ensure they function as expected.

  • Use GenAI as a Starting Point: Even if you are familiar with regular expressions, using the AI to generate a starting point can save time and effort.

  • Provide examples: In the hint message, provide a valid example of the expected input.

Frequently Asked Questions

Q: Can I use Validators on any type of form field?

A: Validators can be used on most common form field types, including text fields, number fields, and email fields - as long as they are <textarea> or <input> HTML elements.

Q: Can a single Validator be used on multiple elements on a page?

A: No. Validators are designed to work on a one-to-one basis with form fields. This is because the selector used to apply a Validator targets a specific, single element within the application.

Q: Can I edit a Validator after it has been published?

A: Yes, you can edit a Validator at any time.

Q: How do I write a regular expression?

A: Regular expressions can be complex, but our GenAI feature can generate them for you. There are also many online resources and tutorials available to help you learn more about regular expressions.

Troubleshooting

If you encounter any issues with Validators, please contact our support team for assistance.

User Icon

Thank you! Your comment has been submitted for approval.