anshu-krishna / data-validator
A PHP library for simplifying complexly-structured-data validation.
2.6.3
2023-07-06 11:26 UTC
Requires
- php: >=8.1
- anshu-krishna/php-utilities: ^2.0
README
A PHP library for simplifying complexly-structured-data validation.
Note: Version >=2.0 is incompatible with older versions.
Installation
composer require anshu-krishna/data-validator
Features:
-
Supported types:
bool
: Boolean valueemail
: String containing an email addressfloat
: Float valuehex
: String containing a hex valueint
: Int valueipv4
: String containing an IPv4 addressipv6
: String containing an IPv6 addressmac
: String containing a MAC addressmixed
: Any valuenull
: Null valuenumber
: Int or Float valuestring
: String valuetimestamp
: String containing a timestamp.
eg: '2021-01-31', 'today', 'yesterday', '01-Jan-2021', 'January 1, 2021 05:00:10 AM GMT+05:30', etc.unsigned
: Int >= 0url
: String containing a URL
-
Custom data types can also be added. For example see
./examples
-
Multiple alternative data types can be set for a data item. eg:
'int|float|null'
,'ipv4|ipv6'
, etc. -
Supports Ranger/Formatter for validated data