Download the PHP package azi/validator without Composer
On this page you can find all versions of the php package azi/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azi/validator
More information about azi/validator
Files in azi/validator
Package validator
Short Description Server side user input validation library
License MIT
Informations about the package validator
This Package is Abandoned in favor if https://github.com/azeemhassni/envalid
PHP Server Side Form Validation
This is a small PHP package that makes it easy to validate forms in your project specially larger forms.
Installation Guide:
You can install Validator either via package download from github or via composer install. I encourage you to do the latter:
Usage
to get started
-
require composer autoloader
-
Instantiate the Validator class
-
Define Rules for each form field
-
Run the validator
-
check validator for errors, if validation fails redirect back to the form
- show validation errors to user
you can wrap error messages with custom HTML markup
Rules
- required
- num
- alpha
- alnum
- ip
- url
- min:number
- max:number
- same:field_name
Custom Expressions & Messages
- Custom Expressions
you can register your custom RegExp before running the validator
registerExpression method takes 3 arguments
- expressionID - unique name for the expression
- pattern - the RegExp string
-
message [optional] - the error message to be retured if the validation fails
- Custom Messages
you can also pass a custom error message with each rule
Registring custom rules
this weekend (15th Aug 2015) i was working on a must have feature in validator which is accepting custom rules at run time. here is how you can do it from now on.
now you can use this newly registered rule.
now you have so much power on your fields validation do whatever you want in Closure you passed to as 2nd argument.
Conditional Rules
you can spacify conditional rules for a field
Comparison Rules
you can also compare a field with another