Download the PHP package renanhangai/validator without Composer
On this page you can find all versions of the php package renanhangai/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download renanhangai/validator
More information about renanhangai/validator
Files in renanhangai/validator
Package validator
Short Description Validate any php variable using a very simple sintax.
License MIT
Informations about the package validator
Validator
Validate objects against easily defined rules (See API Reference)
Installation
Getting Started
Simply validate some data
Another Example
Simply validate some data
Chainability
Every method can be chained by using ->
API Reference
Summary
- Type validators
any()
arrayOf($rule)
boolval()
b()
date($format = null, $out = null)
decimal($digits, $decimal, $decimalSeparator = null, $thousandsSeparator = null)
floatval($decimal = null, $thousands = null, $asString = false)
f($decimal = null, $thousands = null, $asString = false)
instanceOf($type)
intval()
i()
obj($definition)
strval($trim = true)
s($trim = true)
- String rules
blacklist($chars)
len($min, $max = null)
minlen($min)
preg_replace($search, $replace)
regex($pattern)
str_replace($search, $replace)
whitelist($chars)
- Mixed
call($fn)
map($map)
set($items)
- Locale rules
cnpj()
cpf()
- Meta
dependsOn()
- Obligatoriness
optional()
required()
skippable()
- Numeric rules
range($min, $max)
Methods
-
Validate all objects
-
Validate every element on the array against the $rule
-
Remove any char found in $chars from the string
-
Convert the value to a boolean
-
Call the function $fn to validate the value
-
Brazilian CNPJ validator
-
Brazilian CPF validator
-
date($format = null, $out = null)
Convert the value to a date using the format (or keep if alredy a \DateTime)
-
decimal($digits, $decimal, $decimalSeparator = null, $thousandsSeparator = null)
Convert the value to a decimal with $digits and $decimal (needs rtlopes\Decimal)
-
Add a rule dependency. (Only works for objects)
-
floatval($decimal = null, $thousands = null, $asString = false)
Convert the value to a float
-
Check if the object is an instance of the given type
-
Convert the value to an int and fails if cannot be safely convertible
-
Check for string or array length
-
Map a value to another
-
Check if string has at least $min length
-
Convert the value to an object and validate its fields
-
Optional validator (Bypass if null or '')
-
preg_replace($search, $replace)
Replace the $search pattern on the string using $replace (Callback or string)
-
Range validator
-
Validate the value against the $pattern
-
Required validator (Fails if null or '')
-
Check if value is in set
-
Skippable validator (Bypass if null or '' and does not set the property)
-
str_replace($search, $replace)
Replace the characters on the string
-
Convert the object to a string value
-
Remove any char NOT found in $chars from the string