Download the PHP package project-melody/validator without Composer
On this page you can find all versions of the php package project-melody/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download project-melody/validator
More information about project-melody/validator
Files in project-melody/validator
Package validator
Short Description Set of Validation Rules
License BSD Style
Homepage https://github.com/project-melody/validator
Informations about the package validator
Melody Validator
Melody Validator is a set of validation rules with an easy way to customize validation groups. It works with PHP 5.3.3 or later.
- You can use chained validation like: v::email()->noWhitespace()->length(5,20)->validate("[email protected]");
- You can set custom messages
- You can reuse the rules as you wish in a smart way
- You can load validation groups from YML and PHP files
- PSR-0 autoloading is compatible.
Installation
The recommended way to install Melody Validator is through
composer. Just create a composer.json
file and
run the php composer.phar install
command to install it:
{
"require": {
"project-melody/validator": "dev-master"
}
}
Introduction
Importing Validator namespace:
Basic Usage
Chained validation
Getting violation messages
Constraints reuse
Rules
Alnum
Only alphanumeric strings accepted:
Boolean
Only boolean accepted:
ContainsDigit (integer $minimum)
Minimum of digits (0-9) occurences in the input string:
ContainsLetter (integer $minimum)
Minimum of letters (a-z or A-Z) occurences in the input string:
ContainsSpecial (integer $minimum)
Minimum of special characters occurences in the input string:
Only valid emails accepted:
Int
Asserts if the input is an integer:
IsArray
Asserts if the input is an array:
KeyExists
Asserts if the key exists in the array:
Length (integer $minLength, integer $maxLength)
Ensures that the length of the string is between the min and max:
Max (integer $input)
Requires a given maximum number:
Min (integer $min)
Requires a given minimum number:
MaxLength (integer $max)
Validates if the string has the maximum length specified
MinLength (integer $min)
Validates if the string has the minimum length specified
NotEmpty ()
Validates if the input is not empty:
NoWhitespace ()
Validates if a string contains no whitespace:
Number ()
Validates if the input is numeric:
Range (integer $min, integer $max)
Validates if a number is between the minimum and maxim specified:
String ()
Validates if the input is a string:
Group Validation
This is the input we will use as reference to test the validation group:
Load from array
Load from YAML file
Validation:
Load from PHP file
Validation: