Validate Regex
Validates an email address format using regex pattern matching. This is the fastest validation method, checking if the email address follows standard email syntax patterns without making any network calls.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Input
-
Configuration Id - Configuration ID from the Configuration node. This ID references the validation configuration to use.
-
Email Address - Email address to validate using regex pattern. The email will be checked against the regex pattern defined in the configuration.
Output
-
Result - Validation result object containing success status and pattern match details. The structure depends on the "Is Valid" option.
When "Is Valid" is disabled (default), returns full result object:
{
"Success": true,
"Email": "user@example.com",
"ValidationType": "regex",
"Domain": "example.com",
"Configuration": {...}
}When "Is Valid" is enabled, returns simplified result:
{
"IsValid": true
}
Options
- Is Valid - When enabled, returns only the IsValid boolean instead of the full result object. Default: false.
- Disabled - Returns complete validation result with all details
- Enabled - Returns only
{"IsValid": true}or{"IsValid": false}
How It Works
The Validate Regex node performs fast client-side validation:
- Retrieves the Configuration ID and email address
- Looks up the configuration object
- Applies the regex pattern from the configuration to the email address
- Checks if the email matches the pattern
- Returns the validation result
This validation method:
- Does not make any network requests
- Checks only the format/syntax of the email
- Cannot verify if the email address actually exists
- Is the fastest validation method available
When to Use Regex Validation
Best For:
- Quick format validation before expensive operations
- Client-side validation in web forms
- Pre-filtering email lists before deeper validation
- High-volume processing where speed is critical
- Initial validation step in multi-stage validation
Not Suitable For:
- Verifying email addresses actually exist
- Detecting disposable email services (use MX Blacklist instead)
- Checking if a mailbox can receive emails (use SMTP instead)
- Validating domain validity (use MX instead)
Usage Examples
Basic Email Format Validation
// Set configuration ID from Configuration node
msg.con_id = msg.configId;
// Email to validate
msg.emailToValidate = "john.doe@example.com";
// After Validate Regex node
if (msg.result.Success) {
console.log("Email format is valid");
} else {
console.log("Email format is invalid");
}
Batch Email Validation
// List of emails to validate
const emails = [
"valid@example.com",
"invalid@",
"another.valid@company.co.uk",
"bad-format@"
];
const results = [];
for (const email of emails) {
msg.emailToCheck = email;
// Validate Regex node processes here
// (use Loop node in actual workflow)
results.push({
email: email,
isValid: msg.result.Success
});
}
// Filter only valid emails
const validEmails = results
.filter(r => r.isValid)
.map(r => r.email);
console.log("Valid emails:", validEmails);
Using Simplified Output
// Set configuration ID
msg.con_id = msg.configId;
// Email to validate
msg.emailAddress = "test@example.com";
// Enable "Is Valid" option in node
// After Validate Regex node with Is Valid enabled
if (msg.result.IsValid) {
console.log("Email format is valid");
// Proceed with further processing
} else {
console.log("Email format is invalid");
// Reject or flag for manual review
}
Custom Regex Pattern Validation
// In Configuration node, set custom pattern
// Email Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
msg.con_id = msg.configId;
msg.emailAddress = "user@example.com";
// Validate Regex node uses custom pattern
if (msg.result.Success) {
console.log("Email matches custom pattern");
}
Pre-Filter Before Expensive SMTP Validation
// Step 1: Quick regex check
msg.con_id = msg.configId;
msg.emailAddress = msg.userEmail;
// After Validate Regex node
if (msg.result.Success) {
// Email format is valid, proceed to SMTP validation
console.log("Format valid, checking with SMTP...");
// Continue to Validate SMTP node
} else {
// Format is invalid, skip expensive SMTP check
console.log("Invalid format, skipping SMTP validation");
msg.validationFailed = true;
}
Validation with Error Details
msg.con_id = msg.configId;
msg.emailAddress = "potentially-invalid@";
// After Validate Regex node (Is Valid disabled)
const result = msg.result;
console.log("Email:", result.Email);
console.log("Valid:", result.Success);
console.log("Validation Type:", result.ValidationType);
console.log("Domain:", result.Domain);
if (!result.Success) {
// Log detailed error for troubleshooting
console.log("Validation failed for:", result.Email);
}
Error Handling
The Validate Regex node returns specific errors in these cases:
-
ErrInvalidArg
- Configuration ID is empty
- Email Address is empty
-
ErrNotFound
- Configuration not found for the provided Configuration ID
-
ErrInternal
- Failed to retrieve Configuration ID or Email Address
- Failed to set output result
-
ErrRuntime
- Failed to validate email via regex (pattern matching error)
Best Practices
-
Use as First Validation Step
- Run regex validation before expensive network-based validation
- Filter out obviously invalid emails early
- Save time and resources on batch processing
-
Choose Appropriate Pattern
- Use standard pattern for general validation
- Use stricter pattern if you need specific format requirements
- Test custom patterns thoroughly before production use
-
Combine with Other Validation Methods
- Use regex for quick format check
- Follow up with MX validation to verify domain
- Use SMTP for final verification of important emails
-
Handle Results Appropriately
- Use full result object when you need detailed information
- Use simplified IsValid for simple pass/fail decisions
- Log validation details for troubleshooting
-
Performance Optimization
- Enable "Is Valid" option when you only need pass/fail
- Reuse same Configuration ID for batch processing
- Consider caching results for frequently checked emails
Performance Characteristics
- Speed - Fastest validation method (microseconds)
- Accuracy - Format only, cannot detect if email exists
- Network - No network calls required
- Resource - Minimal CPU and memory usage
- Scalability - Excellent for high-volume processing
Common Validation Patterns
Standard Email Pattern
Validates standard email format with common TLDs:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Strict Email Pattern
More restrictive pattern for enterprise use:
^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$
Permissive Email Pattern
Allows more characters and formats:
^[^\s@]+@[^\s@]+\.[^\s@]+$
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "Configuration Id cannot be empty" | Configuration ID input not set | Ensure Configuration node runs first and ID is passed |
| "Email Address cannot be empty" | Email input not provided | Check that Email Address input has a value |
| "Configuration not found" | Invalid Configuration ID | Verify Configuration ID is correct and configuration exists |
| "Failed to validate email via Regex" | Invalid regex pattern | Check custom Email Pattern in Configuration is valid |
Tips for Effective Use
-
Multi-Stage Validation Strategy
Regex (format) → MX (domain exists) → SMTP (mailbox exists) -
Fast Rejection of Invalid Formats
- Use regex to quickly reject malformed emails
- Reduces load on subsequent validation steps
-
Whitelist/Blacklist Integration
- Check domain blacklist after regex validation
- Skip expensive validation for known bad domains
-
Logging and Analytics
- Track validation success rate
- Identify common format errors
- Improve input validation on forms
-
Custom Pattern for Specific Requirements
- Company email only:
^[a-z.]+@company\.com$ - No special characters:
^[a-zA-Z0-9.]+@[a-zA-Z0-9.]+$ - Specific TLDs:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.(com|org|net)$
- Company email only: