How to configure regex validation for custom properties
Introduction
This article guides platform administrators and users through configuring regex validation for custom property fields. Regex validation ensures that user-entered data follows predefined patterns, improving data consistency and accuracy across all system entities including organizations, subscriptions, orders, and contracts.
In this article:
- Setting Up Regex Validation
- Creating Custom Property Templates with Validation
- Using Custom Properties with Validation
- Validation Error Handling
- Common Regex Patterns
Setting Up Regex Validation
Prerequisites
- Administrative access to Settings > Custom Fields
- Understanding of basic regex patterns
- Appropriate permissions for custom property management
When Regex Validation Is Available
The Regex validation field appears only when you select specific field types during custom property template creation:
- Text fields
- Number fields
Creating Custom Property Templates with Validation
Step 1: Access Custom Fields Settings
- Navigate to Settings > Custom fields
- Click Add new to create a custom property template
- Enter the required Name for your custom field
- Select the appropriate Entity from the droplist for Organization, Subscription, Contract or Order:
Step 2: Configure Field Type and Validation
- In the Type dropdown, select either:
- Text - for alphanumeric content validation
-
Number - for numeric pattern validation
- The Regex validation field will appear automatically below the Type field
- Enter your regex pattern in the Regex validation field (optional)
- Leave empty if no validation is required
- Use standard regex syntax (e.g.,
/^PO\d{6}$/
)
- Configure additional settings:
- Check Is required if the field must be completed
- Check Only allow to set value once if the field should be read-only after initial entry
- Select appropriate Display Locations where the field should appear
Step 3: Save the Template
Click Save to create the custom property template with regex validation.
Using Custom Properties with Validation
Entering Valid Data
When entering data in custom fields with regex validation:
- Type your value in the custom property field
- The system validates the input against the defined regex pattern in real-time
- If the value matches the pattern, you can proceed normally
- If validation passes, the Save button remains active
Example Use Cases
Purchase Order Numbers: Use regex /^PO\d{6}$/
to ensure all PO numbers start with "PO" followed by exactly 6 digits (e.g., PO123456).
Incorrect value:
Correct value:
Date Formats: Use regex /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/
to enforce DD/MM/YYYY format (e.g., 12/08/2024).
Incorrect value:
Correct value:
Email Addresses: Use regex /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
to validate email format for Orders.
Incorrect value:
Correct value:
Code Prefixes: Use regex /^000.+/
to ensure values start with "000".
Incorrect value:
Correct value:
Validation Error Handling
Error Messages
When validation fails, the system displays:
- Generic Error: "The Regex you have defined is not valid!"
- Specific Error: "Custom field '[Field Name]' is invalid according to validation regex '[Pattern]'"
Error Behavior
- Save Button: Becomes inactive when validation fails
- Visual Indicators: Error messages appear in red text boxes
- Field Highlighting: Invalid fields are highlighted with red borders
- Data Prevention: Invalid data cannot be saved to the system
Resolving Validation Errors
- Review the Error Message: Check which field and pattern caused the validation failure
- Correct the Input: Modify your entry to match the required pattern
- Verify Pattern: Ensure your input follows the exact regex requirements
- Retry Submission: The error will clear automatically when valid data is entered
Common Regex Patterns
Text Patterns
-
Alphanumeric with prefix:
/^ABC\d{3,6}$/
(ABC followed by 3-6 digits) -
Capital letter start:
/^[A-Z].*/
(Must start with capital letter) -
Specific format codes:
/^[A-Z]{2}\d{4}$/
(Two letters, four numbers)
Number Patterns
-
Fixed digit count:
/^\d{6}$/
(Exactly 6 digits) -
Range validation:
/^[1-9]\d{2,5}$/
(3-6 digits, no leading zeros) -
Specific number endings:
/^[1-9]{3}999$/
(Three non-zero digits ending in 999)
Date Patterns
-
DD/MM/YYYY:
/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/
-
YYYY-MM-DD:
/^\d{4}-\d{2}-\d{2}$/
-
MM-DD-YYYY:
/^\d{2}-\d{2}-\d{4}$/
Contact Information
-
Phone Numbers:
/^\+?[1-9]\d{1,14}$/
(International format) -
Email Validation:
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
-
Postal Codes:
/^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$/
(UK format)
Limitations
- Validation patterns must follow standard JavaScript regex syntax
- Complex validation logic may require multiple custom fields rather than a single regex pattern
- Regex validation cannot be applied retroactively to existing data entries
- Performance may be impacted with extremely complex regex patterns
Summary
Regex validation for custom properties provides powerful data quality control across all system entities. By configuring appropriate validation patterns, administrators can ensure consistent data entry while providing clear feedback to users when validation fails. The feature works seamlessly across organizations, subscriptions, orders, and contracts, maintaining data integrity throughout the platform.
Add comment
Please sign in to leave a comment.