Custom username validation

Component ID

337789

Component name

Custom username validation

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

10826

Component created

Component changed

Component body

For a customer, i needed to validate the username against a german phone number, so i wrote this little module that allows to define a validation pattern for the username on registration. it's also possible to customize the error message on validation failure.

Other modules can make use of the validation as well using the function:
custom_username_validation_validate_username($username)

Notes

  • If you are experiencing problems in testing the pattern, please clear your site cache.
  • To result in an exact match (not partial) your regular expression should start with ^ (asserts position at start of string) and end with $ (asserts position at end of string).