Exceptions

 
cim1265
 
AttributeValidationException is thrown when a validation rule cannot validate an attribute value supplied in a task screen field or programmatically. The exception contains one or more messages that are presented to the user, enabling the user to correct the entry and resubmit the task.
How this exception is thrown and how the error messages are presented for the exception depends on whether the rule is implemented as JavaScript, a Java class, or a regular expression.
This page contains the following topics:

Exceptions with Task-Level Validation

With task-level validation errors, AttributeValidationException is thrown as shown in the following table:
Rule Type
How Thrown
Error Message Source
Regular expression
By
Identity Manager
if the regular expression validation fails.
Identity Manager
uses a generalized exception message.
JavaScript
By
Identity Manager
if the validate() method returns False.
The
errorMessage
parameter of the validate() method.
Java
By the custom validation rule or by
Identity Manager
.
Identity Manager
throws the exception when the custom rule does not and the custom rule’s validate() method returns False.
One of the following sources:
If the custom validation rule throws the exception, the exception’s constructor. The constructor lets you specify the ID of a message in a resource bundle and the text of an additional message.
If
Identity Manager
throws the exception, the
errorMessage
parameter of the validate() method.
If the validation rule implementation does not provide an error message,
Identity Manager
uses a generalized error message.

Exceptions with Directory-Level Validation

Exception messages for directory-level validation errors come from two sources:
  • A resource bundle. In directory.xml, definitions of all types of validation rules (Java, JavaScript, and regular expression) include the attribute messageid. This ID maps to a custom exception message in the resource bundle IMSExceptions.properties. When AttributeValidationException is thrown,
    Identity Manager
    includes the mapped message with other error information that may be defined for the validation rule.
  • Custom validation rule code. Java and JavaScript implementations can define additional exception messages for the rule. If a validation error occurs in the Java or JavaScript rule, the message is presented to the user with the message that is mapped to the rule in the resource bundle.
    The sources of these Java and JavaScript exception messages are defined in the previous table.
    This feature does not apply to directory-level validation rules implemented as regular expressions.
For more information about exception messages in resource bundles, see AttributeValidationException in the
Identity Manager
Javadoc.

AttributeValidationException Constructor

When you create an AttributeValidationException object for a Java validate() method, use the following constructor:
  • Syntax
    public AttributeValidationException(String attrName,        String attrValue,        String messageid,        String message);
  • Parameters
    • attrName
      Specifies the name of the managed object attribute being validated.
    • attrValue
      Specifies the value to validate.
    • messageid
      If the value cannot be validated, it provides the ID associated with the message to display. The ID corresponds to a message in the resource bundle IMSExceptions.properties.
    • message
      Provides an additional message that can be displayed to the user. This parameter gives you an opportunity to display a more specific message than the one in the resource bundle, or a message from a custom resource bundle.
For more information about AttributeValidationException, see the
Identity Manager
Javadoc.