Download the PHP package ndaedzo/violin without Composer
On this page you can find all versions of the php package ndaedzo/violin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ndaedzo/violin
More information about ndaedzo/violin
Files in ndaedzo/violin
Package violin
Short Description Violin is an easy to use, highly customisable PHP validator.
License MIT
Homepage https://github.com/kxngHADES/violin
Informations about the package violin
violin
Violin is an easy to use, highly customisable PHP validator.
Note: This package is under heavy development and is not recommended for production.
Installing
Install using Composer.
Basic usage
Adding custom rules
Adding custom rules is simple. If the closure returns false, the rule fails.
Adding custom error messages
You can add rule messages, or field messages for total flexibility.
Adding a rule message
Adding rule messages in bulk
Adding a field message
Any field messages you add are preferred over any default or custom rule messages.
Adding field messages in bulk
Error output
Errors are output categorised by field, so you're free to play around with them in whatever way you need them output.
Extending the Violin class
You can extend Violin to implement your own validation class and add rules, custom rule messages and custom field messages.
Rules
This list of rules are in progress. Of course, you can always contribute to the project if you'd like to add more to the base ruleset.
activeUrl
If the URL provided is an active URL using checkdnsrr().
alnum
If the value is alphanumeric.
alnumDash
If the value is alphanumeric. Dashes and underscores are permitted.
alpha
If the value is alphabetic letters only.
alphaDash
If the value is alphabetic letters only. Dashes and underscores are permitted.
bool
If the value is a boolean.
If the value is a valid email.
int
If the value is an integer, including integers within strings. 1 and '1' are both classed as integers.
required
If the value is present.
Contributing
Please file issues under GitHub, or submit a pull request if you'd like to directly contribute.
Todo
-
Allow parameter based rules. For example:
- Improve error storage so
errors[]doesn't contain a list of strings, but a list of messages to look up. Rough example:
Then when calling errors(), this should collect up errors for that field, build the string and return them.
- Allow errors to be defined with {field} and {value} rather than %s's for greater flexibility.