Introduction
In IriusRisk, custom fields provide a powerful way to capture specific information tailored to your project's needs. You can go beyond mere data collection by enforcing data quality through regular expression (regex) validation. This guide will walk you through the process of adding and validating a custom field for email addresses using regex, ensuring accurate and consistent data entry.
Creating a Custom Field
Before diving into regex validation, make sure you have a clear understanding of how to create a custom field in IriusRisk. If you need assistance with this step, refer to the article: How to Create a Custom Field.
Use Case: Email Address Validation
For the purpose of this guide, let's consider a scenario where you want to capture users' email addresses during project creation and validate them using regex to ensure they belong to a specific domain, such as "example.com."
-
Creating the Custom Field:
Start by adding a custom field to your project. In this example, we'll create a custom field to capture users' email addresses.
-
Enforcing Validation:
Once you've added the custom field, you can set it as required and apply regex validation to ensure the entered data follows a specific format. In this case, we're using the regex
^[a-zA-Z0-9_.-]+@example\.com$
.Breakdown of the regex components:
^
: Indicates the start of the line or string.[a-zA-Z0-9_.-]+
: Character set for the local part of the email address. It includes letters (uppercase and lowercase), digits, underscores, periods, and hyphens. The+
sign requires one or more of these characters.@
: A literal "@" symbol.example\.com
: Specifies the required domain ("example.com"). The\.
escapes the dot to treat it as a literal dot.$
: Marks the end of the line or string.
This regex pattern ensures that the email address adheres to the given format.
Examples: Good and Bad
To illustrate how regex validation works, consider the following examples:
-
Good Example:
Suppose a user enters the email address "john.doe@example.com" in the custom field. The regex validation will successfully match this input against the pattern
^[a-zA-Z0-9_.-]+@example\.com$
, as it adheres to the format of the local part and domain. This input will be accepted. -
Bad Example:
Now, imagine the user enters "invalid.email@test.com" in the custom field. This input violates the regex pattern's requirement for the domain to be "example.com." As a result, the validation will fail, and an error message should prompt the user to enter a valid email address with the correct domain.
Conclusion
Using regex validation for custom fields in IriusRisk enhances the quality of data captured in your custom fields. By ensuring that information follows specific formats and criteria, you can minimize errors and maintain consistent data across projects. In this guide, we focused on email address validation using a regex pattern that checks for a specific domain. Apply similar principles to other custom fields as needed, tailoring the regex patterns to your requirements.
Remember to refer to the provided How to Create a Custom Field article for more details on creating custom fields in IriusRisk. With regex validation, you're well-equipped to collect accurate and structured data in your projects.
Comments
0 comments
Please sign in to leave a comment.