Download the PHP package olegkishko/php-field-validator without Composer
On this page you can find all versions of the php package olegkishko/php-field-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olegkishko/php-field-validator
More information about olegkishko/php-field-validator
Files in olegkishko/php-field-validator
Package php-field-validator
Short Description Lightweight, extensible validation library with chainable rules.
License MIT
Informations about the package php-field-validator
PHP Field Validator
A flexible and extensible PHP validation library that allows you to create chain validation rules for your data fields.
Features
- Chain multiple validation rules
- Built-in validation rules
- Custom validation rules support
- Callback-based validation
- Easy to extend and implement
Installation
Basic Usage
Built-in Rules
array()- Validates if value is an arraybetween(int $min, int $max)- Validates if numeric value is between specified rangeboolean()- Validates if value is a booleancontains(string $needle)- Validates if value contains a substringcount(int $count)- Validates if value is an array and consists of the specified number of elementsdistinct()- Validates if value is an array and all elements are uniqueeach(array $rules)- Validates if value is an array and each element is valid, according to the rulesemail()- Validates email formatendsWith(string $suffix)- Validates if value ends with a suffixequals(string|int|float|array $to)- Validates if value equals to passed valuefalse()- Validates if value is a boolean FALSEfloat()- Validates if value is a floatin(array $choices)- Validates if value is in passed choicesinteger()- Validates if value is an integerip(string $version)- Validates if value is an IP (any, ipv4 only, ipv6 only)length(int $length)- Validates if value is a string with the specified lengthmaxCount(int $maxCount)- Validates if value is an array and contains no more the specified number of elementsmaxLength(int $length)- Validates if value is a string and its length is not more than the specified lengthmax(int|float $max)- Validates if value is a numeric and not more than the specified valueminCount(int $minCount)- Validates if value is an array and contains at least the specified number of elementsminLength(int $length)- Validates if value is a string and its length is at least the specified lengthmin(int|float $min)- Validates if value is a numeric and at least the specified valueinteger()- Validates if value is a negative numericnotBlank()- Validates if value is not emptynotEquals(string|int|float|array $to)- Validates if value not equals to passed valuenotIn(array $choices)- Validates if value is not in passed choicesnumeric()- Validates if value is numericpositive()- Validates if value is a positive numericregex(string $pattern)- Validates value against a custom regex patternrequired()- Validates if value is not emptystartsWith(string $prefix)- Validates if value starts with a prefixstring()- Validates if value is a stringtrue()- Validates if value is a boolean TRUEurl()- Validates URL format
Chaining Rules
You can chain multiple rules for complex validation scenarios:
Callback Rules
Use callback rules for custom validation logic:
Custom Rules
You can create custom validation rules by implementing the RuleInterface:
Error Messages
When validation hasErrors, you can retrieve error messages:
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.