X

It's All About the Platform.

Regular Expression Examples for Validation

Guest Author

Introduction

Field and Object validation is crucial in maintaining data integrity when processing user input data. This post covers some exmples of field validation and object validation using regular expression patterns to catch illegal entry by the user.

Background

To understand how to setup Field or Object validation see this blog post. This post looks at regular expression patterns as a way to validate entries.

Regular Expression Patterns

Below is a table of all the entries that we could use for field validation.

Pattern Type Regex Pattern
Text only
/^[a-zA-Z]+$/
Numeric characters only
/[0-9]+/
Check for leading and trailing whitespace
/(^\s)|(\s$)/
Check for any whitespace
/(\s)+/
Lower case sensitivity check
/[a-z]+/
Uppercase sensitivity check
/[A-Z]+/
Title case sensitivity check
/(\s[A-Z]){1}/ 
Validate email is entered
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
Dangerous Html Tags
</?(?i:script|embed|object|frameset|frame|iframe|meta|link|style)(.|\n)*?>
Western European Language Check
/^(en|fr|de|es|nl|it)$/
Weblink check
/(http)(s)?(:\/\/)/
International telephone number check
/^\+(\d+\s?)+$/

The above examples are starting points for creating both field and object validations in application composer.

Field Validation Example

From the above table let's take two examples and apply them in application composer.

Field validation rules in Application Composer

As you can see the first validation rule checks for that user input in the field 'Text Field 1' only contains upper case letters. Anything else will trigger the associated error message.

The second rule checks for an international phone number input for 'Text Field 2'. So input must begin with a '+' followed by numerical digits. Spaces between the digits are allowed.

Field validation error messages

 

In the screenshot above you can see that the field validation rules are effective because the text entered has not met the criteria set in the rules.

Further Information

For further information on this subject have a look at the following...

 

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.