Implement Custom Validation Rules with Java

A Java-based validation rule must implement the relevant interface, depending on whether the rule is used for task-level validation or directory-level validation.
cim1265
A Java-based validation rule must implement the relevant interface, depending on whether the rule is used for task-level validation or directory-level validation.
At validation time,
Identity Manager
calls validate() and passes the value to be validated.
This page contains the following topics:
Java Interface for Task-Level Validation
The definition of the Java interface for task-level validation is as follows:
  • Syntax
    public interface TaskValidator { public class StringRef {    public String reference = new String();    public String toString(){return reference;} public boolean validate(    BLTHContext ctx,    String attrValue,    StringRef updatedValue,    StringRef errorMessage    ) throws AttributeValidationException; }
  • Parameters
    • ctx
      Input parameter
      Specifies an object that contains methods for retrieving information in the current task session.
    • attrValue
      Input parameter
      Specifies the value of the attribute being validated.
    • updatedValue
      Output parameter
      Provides an optional transformation value that replaces the user-supplied value being validated. When no transformation is necessary, pass back null.
    • errorMessage
      Output Parameter
      If validation fails, it displays a message to the user.
  • Comments
    For more information about Java validation rules and on managed objects, see the 
    Identity Manager
    Javadoc.
  • Returns
    • True -- the implementation considers the value in
      attributeValue
      to be valid, or it passes back a transformed value in
      changedValue
      .
    • False -- the implementation considers
      attributeValue
      to be invalid.
  • Throws
    AttributeValidationException
Java Interface for Directory-Level Validation
The definition of the Java interface for directory-level validation is as follows:
  • Syntax
    public interface IAttributeValidator { public class StringRef {    public String reference = new String();    public String toString(){return reference;} public boolean validate(    Object attributeValue,    StringRef changedValue,    StringRef errorMessage    ) throws AttributeValidationException; }
  • Parameters
    • attributeValue
      Input parameter
      Specifies the value of the attribute being validated.
    • changedValue
      Output parameter
      Provides an optional transformation value that replaces the user-supplied value being validated. When no transformation is necessary, pass back null.
    • errorMessage
      Output parameter
      If validation fails, it displays a message to the user.
  • Comments
    If the validation operation requires managed objects from the directory, use AttributeValidator. This abstract class implements the IAttributeValidator interface, and includes a method for retrieving the managed object providers.
  • Returns
    • True -- the implementation considers the value in
      attributeValue
      to be valid, or it passes back a transformed value in
      changedValue
      .
    • False -- the implementation considers
      attributeValue
      to be invalid.
  • Throws
    AttributeValidationException.