Custom Validator in Oracle ADF (JSF Validator), Email Validation Using Regex

Sharing is Caring

Validation is very important part of any programming language, when we visit any website’s registration form it says “This field is mandatory” or “Email id is not valid”,”Password doesn’t match”, these all are validations. In this post, we’ll learn about custom validator in Oracle ADF

What is a Validator
A computer program or piece of code that checks syntax or value of any field according to a predefined condition is called Validator
Validators are used in every programming/scripting language.

How to Use Custom Validator in ADF Forms-
This is not complex to use validator in ADF forms, means in .jsff or in .jspx pages. Suppose we have a field of EmailId on form and we want to add custom email id validator on this field

To add validator in a field follow these steps

  • Select the field in Form
af:inputText to enter email id


  •  Now go to property inspector and Select Validator, it is empty by default
Custom Validator in Oracle ADF
    • Now click on Validator edit in property inspector and create a validator in ManagedBean of taskflow


  • It will look like this- Default Custom Validator
This validator method validates value of inputText
  • Now we will add custom code to validate EmailId field in this validator

public void emailValidator(FacesContext facesContext, UIComponent uIComponent, Object object) {


	String name=object.toString();

	String expression="^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$";

	CharSequence inputStr=name;

	Pattern pattern=Pattern.compile(expression);

	Matcher matcher=pattern.matcher(inputStr);

	String msg="Email is not in Proper Format";




	throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,null));





  • Now when we run this page, we can see validation
Regex to check Email Id format and in case of failure it show validation message

Cheers 🙂 Happy Learning

Related Posts

6 thoughts on “Custom Validator in Oracle ADF (JSF Validator), Email Validation Using Regex”

  1. hello!,I love your writing very much! share we keep up a
    correspondence more about your post on AOL? I require
    a specialist in this area to resolve my problem. Maybe that’s you!

    Taking a look ahead to peer you.

Leave a Reply

Your email address will not be published. Required fields are marked *