• BC4J
    November 28, 2011

Creating Custom validation rule and register it

Guest Author

What is Validation Rule?

validation rule is a piece of code that performs some check
ensuring that data meets given constraints.

an enterprise application development environment, often it might require developers to have validation be performed based on some logic at several places across projects.
Instead of redundant validation creation, a custom validation rule
provides a library with a validation rules that can be registered
and used across applications.

A custom Validation is encapsulated in a reusable component so that you do not have to write
it every time when you need to do input validation.

Here is how we can easily implement a custom validation that checks for name of an employee to be "KING"

For creating a custom Validation ,

Create Generic Application Workspace "CustomValidator" with
the project "Model"

Create an BC4J based on emp table.

Create a custom validation rule.


In EmpNamerule class, update the
validateValue(..) method as follows: 

public boolean validateValue(Object value) {
EntityImpl emp = (EntityImpl)value;
return false;
return true;

Create ADF Library: Next step would be to create ADF library.

Create ADF library with name lets say testADFLibrary1.jar

Register ADF Library

Next step is to register the ADF library , so that its available across the applications.

Invoke the menu "Tools -> Preferences"
Select the option "Business Components -> Registered Rules" from left pane
Click on button "Pick Library". The dialog "Select Library" comes up with  the user library added
Add new library' that points to the above jar
Check the checkbox "Register" and set the name for the rule


Sample Usage

Here is how we can easily implement a validation rule that restrict the name of the employee not to be "KING".
Create new
Application with BC4J based on EMP table.
Create new validation under Business rule tab for Ename & select the above
custom validation rule.
Run the AppModule tester.


Join the discussion

Comments ( 1 )
  • Juan C. Ruiz Tuesday, December 20, 2011

    Hi there,

    Great article, however the images are not displayed.

    Juan C.

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