A configuration is created by adding an entry with the
gatein.validators.
prefix to the exo.properties
file.
This prefix is followed by a validator name,
a period '.' and a validator aspect.
Currently, there are the following validators and validator aspects:
Validators:
username: Validates the 'Username' field in the Create new/Edit user form.
groupmembership: There is a built-in regex that is currently not used to validate any field:
GROUP_MEMBERSHIP_VALIDATION_REGEX = "^(\\p{Lower}[\\p{Lower}\\d\\._]+)(\\s*,\\s*(\\p{Lower}[\\p{Lower}\\d\\._]+))*$";
email: Validates the Email Address field in the Create new/Edit user form.
displayname: Validates the Display Name field in the Create new/Edit user form.
jobtitle: Validates the Job Title field in the User Profile form.
grouplabel: Validates the Label field in Add new/Edit group form.
pagename: Validates the page name field in the Add new page form. Its label is Page Name if you create a page from the → menu. In the Page Creation Wizard, the label is Node Name.
Validator aspects:
gatein.validators.{validatorName}.length.min
: The minimum length of the validated field.
gatein.validators.{validatorName}.length.max
: The maximum length of the validated field.
gatein.validators.{validatorName}.regexp
:
The regular expression to which the validated field must conform.
gatein.validators.{validatorName}.format.message
: The information message that is displayed
when the field does not conform to the specified regular expression.
See details about the "username" validator as below. For instructions on how to add a new validator (not in the above list), see Developing your own validator.
Configuration of username validator
By default, the username will be validated as follows:
The length must be between 3 and 30 characters.
Only lowercase letters, numbers, underscores (_) and period (.) can be used.
No consecutive underscores (_) or periods (.) can be used.
Must start with a lowercase letter.
Must end with a lowercase letter or number.
Some components that leverage GateIn depend on usernames being all lowercase. Therefore, you are strongly recommended to use a lowercase username only.
If you want to validate that username format is email-like, you could use the following configuration:
# validators gatein.validators.username.regexp=^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ gatein.validators.username.format.message=Username must be a valid email address
When the username field does not conform to this rule, the account is not created and there will be a warning message:
The field "User Name" must match the format "Username must be a valid email address".
In case you do not define gatein.validators.username.format.message
, the value of
gatein.validators.username.regexp
will be used in the warning message:
The field "User Name" must match the format "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$".