You can define custom logic for field validations and then specify them in validation.xml to associate the logic with the master index application. The custom logic is created as a Java class by defining custom Java classes in the Source Package folder of the EJB project. The custom validation classes must implement com.sun.mdm.index.objects.validation.ObjectValidator. The exception thrown is com.sun.mdm.index.objects.validation.exception.ValidationException.
The following topics describe the structure of validation.xml and provide information about custom field validators.
By default, validation.xml defines one validation rule named validate-local-id. This rule defines certain validations that are performed against local ID and system fields before they are entered into the database. The local ID validator verifies that the system code is valid, the local ID format is correct, the local ID is the correct length, and that neither field is null.
The following topics provide information about working with the validation.xml:
You can modify validation.xml using the XML editor. The possible modifications to this file are restricted by the schema definition, so be sure to validate the file after making any changes. When you modify this file, you must regenerate the application and redeploy the project for the changes to take effect.
validation.xml consists primarily of a list of rules. Each rule is defined within the ValidationConfig element and is defined by attributes within a rules element. Table 13 describes the elements and attributes of validation.xml.
Table 13 update.xml File Elements
Element or Attribute |
Description |
---|---|
The configuration information for the validation rules. |
|
The configuration information for a specific validation rule in a rules list. |
|
A rule attribute that specifies a name for the validation rule. |
|
A rule attribute that specifies the name of the class that defines the object to which the validation rule is applied, such as SystemObject or ParentNameObject (where ParentName is the name of the parent object in the Object Definition). |
|
A rule attribute that specifies the complete path of the Java class containing the validation rule. |
Plug the custom validation classes you create into the master index application by specifying the name of the custom plug-in for the class in validation.xml, as shown below.
<ValidationConfig module-name="Validation" parser-class= "com.sun.mdm.index.configurator.impl.validation.ValidationConfiguration" <rules> <rule name="validate-auxiliary-id" object-name="PersonObject" class="com.sun.mdm.index.user.AuxiliaryId"/> <rule name="validate-birth-date" object-name="PersonObject" class="com.sun.mdm.index.user.BirthDate"/> </rules> </ValidationConfig> |