Download the PHP package blakvghost/php-validator without Composer
On this page you can find all versions of the php package blakvghost/php-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blakvghost/php-validator
More information about blakvghost/php-validator
Files in blakvghost/php-validator
Package php-validator
Short Description PHPValidator is a modern PHP library for data validation in your PHP applications. It provides a flexible and extensible way to validate data using predefined rules or by creating custom validation rules.
License MIT
Informations about the package php-validator
![Packagist Version (custom server)](https://img.shields.io/packagist/v/BlakvGhost/php-validator?label=stable) ![Packagist Version (custom server)](https://img.shields.io/packagist/l/BlakvGhost/php-validator?label=Licence) ![Packagist Version (custom server)](https://img.shields.io/packagist/dt/BlakvGhost/php-validator?label=download)
About PHPValidator
PHPValidator is a modern PHP library for data validation in your PHP applications. It provides a flexible and extensible way to validate data using predefined rules or by creating custom validation rules.
Installation
Use Composer to install PHPValidator:
Usage
You can also customize the validation error messages or specify the default language
Features
-
Predefined Rules
: PHPValidator comes with a set of predefined validation rules such as required, string, email, maxLength etc. -
Custom Rules
: Easily create custom validation rules by implementing theRule
Interface. Multilingual Support
: Customize validation error messages based on the application's language using theLangManager
.
List of Predefined Rules
PHPValidator provides a variety of predefined rules that you can use for data validation. Here is a list of some commonly used rules along with examples of their usage:
-
Required Rule
- Ensures that a field is present in the data.
-
String Rule
- Checks if a field is of string type.
-
Email Rule
- Validates that a field is a well-formed email address.
-
Max Length Rule
- Specifies the maximum length of a string field.
-
Confirmed Rule
- Checks if a field's value is the same as another field (commonly used for password confirmation).
-
File Rule
- Validates that a field is a file upload.
-
Accepted Rule
- Validates that a field is
"yes"
,"on"
,"1"
, ortrue
. Useful for checkboxes.
- Validates that a field is
-
Accepted If Rule
- Validates that a field is accepted if another field is equal to a specified value.
-
ActiveURL Rule
- Validates that a field is a valid, active URL.
-
Alpha Rule
- Validates that a field contains only alphabetic characters.
-
Numeric Rule
- Validates that a field contains only numeric characters.
-
Lowercase Rule
- Validates that a field contains only lowercase alphabetic characters.
-
Uppercase Rule
- Validates that a field contains only uppercase alphabetic characters.
-
In Rule
- Validates that a field's value is among a list of predefined values.
-
Nullable Rule
- Allows a field to be
null
or empty.
- Allows a field to be
-
Password Rule
- Validates that a field is a
secure password
.
- Validates that a field is a
-
Same Rule
- Validates that a field's value is the same as the value of another field.
-
Max Length Rule
- Specifies the minimum length of a string field.
-
Not In Rule
- Validates that a field's value is not in a specified set.
-
Required With Rule
- Requires the field to be present if another specified field is present.
-
Valid IP Rule
- Validates that a field's value is a valid IP address.
-
Json Rule
- Validates that a field's value is a valid JSON string.
-
URL Rule
- Validates that a field's value is a valid URL.
-
Alpha Numeric Rule
- Validates that a field's value contains only alphanumeric characters.
-
Boolean Rule
- Validates that a field's value is a boolean.
-
Size Rule
- Validates that the size of a string, integer, array, or file is equal to a specified value.
- Not Required With Rule
- Requires the field not be present if another specified field is present.
Custom Rule
In addition to the predefined rules, you can create custom validation rules by implementing the Rule
Interface. Here's an example of how to create and use a custom rule:
CustomPasswordRule.php
Usage in Validator
-
Use your custom class directly
- Add your custom class to the rules list and use it as if it were native
In this example, we created a CustomPasswordRule that checks if the password is equal to confirm_password. You can customize the passes method to implement your specific validation logic.
Contributing
If you would like to contribute to PHPValidator, please follow our Contribution Guidelines.
Authors
Support
For support, you can reach out to me by email at [email protected]. Feel free to contact me if you have any questions or need assistance with PHPValidator.
License
PHPValidator is open-source software licensed under the MIT license.