- Alpha
- Between
- Boolean
- Date and Time Format
- Equals
- Json
- In
- Image
- Ip
- Max
- Min
- Not in
- Numeric
- Phone Mask
- Required
- Same
- Size
- Url
Checks if current string contains only letters
'firstname' => 'alpha' // in rules
'firstname' => 'Denys ' //true because of auto trim
'firstname' => 'Abra Cadabra' //false
'firstname' => '' //true, because not required
'firstname' => ' ' //false, because empty value
Checks if value is between for string length and number value
'randNum' => 'between:1,50|numeric' // for numeric range
'name' => 'between:3,18' // for string length
'randNum' => '1' //true
'randNum' => '50' //true
'randNum' => '51' //false
'name' => 'Den' //true
'name' => 'DK' //false
Applies only true or false values
'randNum' => 'boolean' // in rules
'randNum' => 'true' //true
'randNum' => 'false' //true
'randNum' => '123' //false
Applies if user value matches datetime pattern
'yearHours' => 'dateFormat:(Y H)' // in rules
'yearHours' => '2012 23' //true
'yearHours' => '2012-23' //false
'yearHours' => '1888 00' //true
Matches email address
'email' => 'email' // in rules
'email' => '[email protected]' //true
'email' => 'test-failed @su.re' //false
<a name="equals"></a>```
### Equals
The field equals to value
```php
'secretCode' => 'equals:mmx' // in rules
'secretCode' => 'mmx' //true
'secretCode' => 'lol' //false
Matches string is Json
'response' => 'json' // in rules
'response' => '[{}]' //true
'response' => '[(\/)O_o{\/}]' //false
'response' => '{"require": {"php": ">=5.4"} }' //true
Checks if value exists in array
'shop' => 'in:Metro, ATB, Silpo' // in rules
'shop' => 'Metro' //true
'shop' => 'McDonalds' //false
If file is image, it works)
'myPhoto' => 'image' // in rules
Check ipv4 or ipv6 for validness
'ipAddr' => 'ip' // in rules
'ipAddr' => '77.132.104.66' //true
'ipAddr' => '77.132.104~66' //false
'ipAddr' => '2607:f0d0:1002:51::4' //true
Checking for string length or value of number less than param
'str' => 'max:5' // string length
'num' => 'max:5|numeric' // for numeric values
'str' => 'hello' //true
'str' => 'world!' //false
'num' => '3' //true
'num' => '-100' //true
'num' => '7' //false
Checking for string length or value of number less than param
'str' => 'min:2' // string length
'num' => 'min:2|numeric' // for numeric values
'str' => 'hello' //true
'str' => 'w' //false
'num' => '2' //true
'num' => '-100' //false
'num' => '7' //true
Checks if value not exists in array
'shop' => 'notIn:Metro, ATB, Silpo' // in rules
'shop' => 'Metro' //false
'shop' => 'McDonalds' //true
Checks if value is number
'age' => 'numeric' // in rules
'age' => '100' //true
'age' => '100kb' //false
Checking if value matches phone mask
'phone' => 'phoneMask:(+38(###)###-##-##)', //define phone mask
'phone' => '+38(052)123-45-67' //true
'phone' => '+38-052-123-45-67' //false
'phone' => 'phone test fails' //false
Checks for field is required and not empty
'value' => 'required' // in rules
'value' => 'yep' //true
'value' => ' ' //false
'value' => '' //false
Check if one field has same value with other
'password_repeat' => 'same:password' // in rules
'password' => '123'
'password_repeat' => '123' //true
'password' => '321'
'password_repeat' => '' //false
Check if string is the same size
'keyCode' => 'required|size:3'
'keyCode' => 'yes' //true
'keyCode' => 'no' //false
Matches url pattern
'site' => 'url' // in rules
'site' => 'http://mmx.com' //true
'site' => 'https://mmx.com' //true
'site' => 'mailto:[email protected]' //true
'site' => 'news:news.yahoo.com' //true
'site' => 'mmx.com' //false
'site' => 'mmx' //false