You are looking at documentation for an older release. Not what you want? See the current release documentation.
The user-configurable validator is implemented by the org.exoplatform.webui.form.validator.UserConfigurableValidator
class.
To validate a field using a user-configurable validator, add the validator to the field like the example below:
addValidator(UserConfigurableValidator.class, validatorName);
where validatorName is a String that must match a validator name configured in exo.properties file.
You can see more codes of adding a validator to a field via UIAccountProfiles.java.
The validator instance can then be configured by adding the relevant information in exo.properties file, for example:
# validators gatein.validators.{validatorName}.length.min=5 gatein.validators.{validatorName}.length.max=10 gatein.validators.{validatorName}.regexp=^u\\d{4,9}$ gatein.validators.{validatorName}.format.message=This value must start with ''u'' and be followed by 4 to 9 digits
The regular expressions used for validation are Java Regular Expressions.
Alternatively, a resource key can also be passed to the addValidator
method
to specify which localized message should be used in case a validation fails, for example:
addValidator(UserConfigurableValidator.class, validatorName, localizationKey);
In which, localizationKey
is defined in a resource bundle.