JavaScript Implementation

A JavaScript-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 JavaScript-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:
 
JavaScript Interface for Task-Level Validation
The definition of the JavaScript interface for task-level validation is as follows:
  • Syntax
    public boolean validate(    BLTHContext context,    String attributeValue,    StringRef changedValue,    StringRef errorMessage    );
  • Parameters
    • context
      Input parameter
      Specifies an object that contains methods for retrieving information in the current task session.
    • 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. If no transformation is necessary, pass back null.
    • errorMessage
      Output parameter
      If validation fails, it displays a message to the user.
      The message is displayed through AttributeValidationException. If the method returns false,
      Identity Manager
      generates this exception.
  • Comments
    The output parameters
    changedValue
    and
    errorMessage
    are of data type StringRef. StringRef is a predefined data type that contains the field
    reference
    to which you assign a value, as shown in the following examples:
    • Add a 1 prefix for a properly formatted telephone number:
      changedValue.reference="+1 " + phoneNumber;
    • Provide an error message for an improperly formatted number:
      errorMessage.reference="Phone number " + phoneNumber +             " does not match the format nnn-nnn-nnnn.";
  • 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.
      Identity Manager
      generates an AttributeValidationException that includes
      errorMessage
      .
JavaScript Interface for Directory-Level Validation
The definition of the JavaScript interface for directory-level validation is as follows:
  • Syntax
    public boolean validate(    String attributeValue,    StringRef changedValue,    StringRef errorMessage    );
  • 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. If no transformation is necessary, pass back null.
    • errorMessage
      Output parameter
      If validation fails, it displays a message to the user.
      The message is displayed through AttributeValidationException. If the method returns false,
      Identity Manager
      generates this exception.
  • Comments
    The output parameters
    changedValue
    and
    errorMessage
    are of data type StringRef. StringRef is a predefined data type that contains the field
    reference,
    to which you assign a value, as shown in the following examples:
    • Add a 1 prefix for a properly formatted telephone number:
      changedValue.reference="+1 " + phoneNumber;
    • Provide an error message for an improperly formatted number:
      errorMessage.reference="Phone number " + phoneNumber +              " does not match the format nnn-nnn-nnnn.";
  • 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.
      Identity Manager
      generates an AttributeValidationException that includes
      errorMessage
      .