Download the PHP package solophp/validator without Composer
On this page you can find all versions of the php package solophp/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package validator
PHP Validator
Solo Validator is a lightweight, standalone PHP validation library designed for simplicity and flexibility. It provides essential validation rules out of the box, supports custom rules and messages, and integrates seamlessly into any PHP project.
Features
- Basic Validation Rules: Includes
required
,email
,phone
,min
,max
,length
, and more - Custom Rules: Extend validation with your own rules
- Custom Error Messages: Override default messages globally or per validation
- Parameterized Rules: Define rules with parameters (e.g.,
min:8
) - Placeholder Support: Dynamic messages with
:field
and:param
placeholders - Standardized Contracts: Uses
solophp/contracts
for consistent validation interface - PSR-4 Compliant: Modern autoloading structure
- Comprehensive Testing: Full test coverage with PHPUnit
- Code Standards: PSR-12 compliant code
Installation
Install via Composer:
Quick Start
Available Validation Rules
Core Rules
- required: The field must not be empty
- email: The field must be a valid email address
- phone: The field must be a valid phone number
- length:value: The field must be exactly
value
characters long - min:value: The field must have a minimum length of
value
- max:value: The field must not exceed
value
in length - filled: The field must not be empty
- integer: The field must be an integer
- string: The field must be a string
- regex: The field must match the provided regex pattern
- numeric: The field must be a number
- array: The field must be an array
- min_value:value: The field must be at least
value
- max_value:value: The field must not exceed
value
- nullable: The field can be null or empty
Example Usage
Custom Validation Rules
Add your own validation logic using addCustomRule()
:
Custom Error Messages
Override default messages globally or during validation:
Error Handling
fails()
: Check if validation failederrors()
: Get all validation errorspassed()
: Check if validation succeeded
Placeholders in Messages
Use :field
and :param
in messages for dynamic content:
Development
Running Tests
Code Standards
Check code standards:
Fix code standards:
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See LICENSE for details.
All versions of validator with dependencies
giggsey/libphonenumber-for-php-lite Version ^8.13
solophp/contracts Version dev-main