Alias plugin

Allow to use multiple instances of the same validator

Usage

If you want to have multiple instances of particular validator, such as different callback validators, the following approach doesn't work:

It is a common case especially when you use an external service to validate field. The Alias plugin is handy for these scenarios.

The following piece of code is the starting point to use the Alias plugin:

The sample code above assumes that the FormValidation files are placed inside the vendors directory. You might need to change the path depending on where you place them on the server.

Basic example

The following example registers various methods to validate a password by different requirements, but all of them are alias of the callback validator:

The Alias plugin gives you the beauty of code because you can split complicate logic into different, smaller, more maintainable parts as seen above.

Changelog

  • v1.0.0: First release

More examples

Related validators

The following validators might be useful to you.