Download the PHP package phputil/validator without Composer
On this page you can find all versions of the php package phputil/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download phputil/validator
More information about phputil/validator
Files in phputil/validator
Download phputil/validator
More information about phputil/validator
Files in phputil/validator
Vendor phputil
Package validator
Short Description Easy and powerful validator for PHP
License LGPL-3
Homepage http://github.com/thiagodp/validator
Package validator
Short Description Easy and powerful validator for PHP
License LGPL-3
Homepage http://github.com/thiagodp/validator
Please rate this library. Is it a good library?
Informations about the package validator
phputil\validator
Easy and powerful validation library for PHP.
We use semantic versioning. See our releases.
Installation
Dependends only on phputil/rtti.
An Example
A step-by-step example for demonstrating its use.
Features
- [x] Validates basic types (see example 1)
- [x] Validates arrays (see example 2)
- [x] Validates dynamic objects (
stdClass) (see example 3) - [x] Validates objects (of user-created classes) with private or protected attributes (see example 3)
- [x] Supports localized validation messages (different locales)
- [x] Supports different string formats (UTF, ISO-8859-1, ASCII, etc.)
Available Rules
- [x]
required - [x]
min_length - [x]
max_length - [x]
length_range - [x]
min_value - [x]
max_value - [x]
value_range - [x]
min_count(for arrays) - [x]
max_count(for arrays) - [x]
count_range(for arrays) - [x]
in(for arrays) - [x]
not_in(for arrays) - [x]
start_with(accepts a string or an array of strings, compared with "or") - [x]
not_start_with(accepts a string or an array of strings, compared with "or") - [x]
end_with(accepts a string or an array of strings, compared with "or") - [x]
not_end_with(accepts a string or an array of strings, compared with "or") - [x]
contains(accepts a string or an array of strings, compared with "or") - [x]
not_contains(accepts a string or an array of strings, compared with "or") - [x]
regex - [x]
format: allows to use a format (see Available Formats) - [x]
with: allows to define rules for sub-arrays or sub-objects. - [x] custom: you can add others easily. See below.
Adding a custom rule
Now checking the custom rule:
Available Formats
- [x]
anything - [x]
string(same asanything) - [x]
name - [x]
word - [x]
alphanumeric - [x]
alpha - [x]
ascii - [x]
numeric - [x]
integer - [x]
double - [x]
float(same asdouble) - [x]
monetary - [x]
price(same asmonetary) - [x]
tax - [x]
date(equals todate_dmy) - [x]
date_dmy - [x]
date_mdy - [x]
date_ymd - [x]
time - [x]
longtime - [x]
datetime(equals todatetime_dmy) - [x]
datetime_dmy - [x]
datetime_mdy - [x]
datetime_ymd - [x]
longdatetime(equals tolongdatetime_dmy) - [x]
longdatetime_dmy - [x]
longdatetime_mdy - [x]
longdatetime_ymd - [x]
email - [x]
http - [x]
url - [x]
ip - [x]
ipv4 - [x]
ipv6 - [x] custom: you can add others easily. See below.
You may specify the separator for date-based formats. Default is "/", for example "31/12/1999".
Adding a custom format
Now checking the format:
Message Replacements
- [x]
{min_length}shows the minimum length; - [x]
{max_length}shows the maximum length; - [x]
{length_range}shows the minimum and the maximum length (e.g. "5-10"); - [x]
{min_value}shows the minimum value; - [x]
{max_value}shows the maximum value; - [x]
{value_range}shows minimum and maximum values (e.g. "5-10"); - [x]
{min_count}shows the minimum count; - [x]
{max_count}shows the maximum count; - [x]
{count_range}shows the minimum count and the maximum count (e.g. "5-10"); - [x]
{in}shows the set of items separated by comma; - [x]
{not_in}shows the set of items separated by comma; - [x]
{start_with}shows the string or the set of strings separated by comma; - [x]
{not_start_with}shows the string or the set of strings separated by comma; - [x]
{end_with}shows the string or the set of strings separated by comma; - [x]
{not_end_with}shows the string or the set of strings separated by comma; - [x]
{contains}shows the string or the set of strings separated by comma; - [x]
{not_contains}shows the string or the set of strings separated by comma; - [x]
{regex}shows the defined regex; - [x]
{label}shows the defined label, if defined. Otherwise, shows the array key or object attribute name; - [x]
{value}shows the value.
Notes:
- [x]
{min_value}and{max_value}are available when the{value_range}is used; - [x]
{min_length}and{max_length}are available when the{length_range}is used; - [x]
{min_count}and{max_count}are available when the{count_range}is used.
More
- [x] Supports UTF-8 and other common formats (ISO-8859-1, Windows-1251, ASCII, etc.)
- [x] Error messages and formats can be specified by locale.
- [x] Error messages and formats can be specified at once. This allows you, for example, read them from a JSON file.
- [x] Formats and rules can be specified without having to extend any class.
- [x] Classes use a fluent interface (that is, you type less).
- [ ] Builder classes available (soon)
Tests
Examples
ex1.php - Validating values
ex2.php - Validating arrays
ex3.php - Validating objects
All versions of validator with dependencies
PHP Build Version
Package Version
The package phputil/validator contains the following files
Loading the files please wait ...