Download the PHP package davebugg/validony without Composer
On this page you can find all versions of the php package davebugg/validony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davebugg/validony
More information about davebugg/validony
Files in davebugg/validony
Package validony
Short Description Powerful and flexible PHP data validator with customizable rules, error messages, and callback functions
License MIT
Homepage https://github.com/DaveBugg/Validony
Informations about the package validony
Validony
Powerful and Flexible PHP Data Validator
Validony is a modern PHP library for data validation that provides flexible capabilities for validating data arrays with customizable rules, error messages, and callback functions.
🚀 Features
- ✅ Array data validation with customizable rules
- ✅ Similar field name validation (e.g.,
password_1
,password_2
) - ✅ Flexible error message system with multi-language support
- ✅ Customizable callback functions for error handling
- ✅ Static and dynamic methods for usage
- ✅ Support for custom validation classes
- ✅ Get all errors or stop on first error
⚠️ IMPORTANT: The default
Checker
,Messages
, andLists
classes included with this library are examples only. For production applications, you should create your own custom classes with validation rules, error messages, and field names specific to your application's needs.
📦 Installation
🔧 Quick Start
Basic Usage
🏗️ Custom Classes - RECOMMENDED APPROACH
⚠️ Important: For production applications, it's highly recommended to create your own custom classes instead of using the default ones. This gives you full control over validation logic, error messages, and field names.
1. Custom Checker Class
Create your own validation methods class based on the default Checker
class:
2. Custom Messages Class
Create your own messages class for multilingual error messages:
3. Custom Lists Classes
Create organized validation rule sets for different forms:
4. Using Custom Classes
Now use your custom classes with Validony:
5. Complete Example with Custom Classes
🛠 Constructor and Settings
Constructor Parameters
Detailed Parameter Description
Parameter | Type | Default | Description |
---|---|---|---|
$post |
array |
- | Required. Data array to validate (usually $_POST ) |
$customMessagesMass |
array\|bool |
false |
Custom error messages array |
$customFieldName |
array\|bool |
false |
Array for renaming fields in messages |
$checkerClass |
mixed |
Checker::class |
Class containing validation methods |
$callback |
array |
[] |
Array [class, method] for callback function |
$errLanguage |
string |
'en' |
Language for error messages |
$printField |
bool |
true |
Include field name in error message |
$printData |
bool |
false |
Include field value in error message |
$getAllErrors |
bool |
false |
Collect all errors (true ) or stop on first (false ) |
$doCallback |
bool |
false |
Automatically call callback when error is found |
📋 Validation Methods
1. CheckData() - Main Validation
Validates data according to specified rules.
Example:
2. ValidateList() - Validation via Rule Lists
Uses predefined rule lists from classes in the Lists folder.
⚠️ Important: The ValidateList
method will use the Checker
class specified in the constructor. If you pass a custom $checkerClass
to the constructor, your Lists classes should reference that custom checker, not the default Checker
class.
Example with Default Checker:
Example with Custom Checker (RECOMMENDED):
How it works:
- Validony looks for the specified method (
registrationRules
) in classes within the Lists folder - The method returns an array of validation rules
- Each rule references methods from the Checker class specified in the constructor
- If you use
MyChecker::class
in constructor, your Lists should useMyChecker::methodName
- If you use default
Checker::class
(orfalse
), your Lists should useChecker::methodName
3. CheckLikeFieldsData() - Similar Fields Validation
Example:
📤 Getting Results
isValid() - Check Validity
getErrors() - Get Errors
Parameters:
$getFields
- iftrue
, also returns field names with errors
Examples:
🎯 Static Methods
For quick usage without creating class instance.
Validon::CheckData()
Validon::ValidateList()
🔧 Configuration Examples
Minimal Setup (NOT RECOMMENDED for production)
Recommended Production Setup
Development Setup with Debugging
Multi-Environment Configuration
🔧 Advanced Examples
Example 1: Complete Registration System
Example 2: Multiple Fields Validation
🌐 Multi-language Support
Using Your Custom Messages Class (RECOMMENDED)
The best approach is to create your own Messages class with all the languages and messages you need:
Dynamic Language Switching
🔍 Debugging and Logging
Enable Detailed Messages
Custom Error Handler
📚 API Reference
Main Methods
Method | Description | Returns |
---|---|---|
__construct() |
Create validator instance | void |
CheckData() |
Validate by rules | bool |
ValidateList() |
Validate via rule lists | void |
CheckLikeFieldsData() |
Validate similar fields | bool |
isValid() |
Check validation result | bool |
getErrors() |
Get errors | array |
Static Methods
Method | Description | Returns |
---|---|---|
Validon::CheckData() |
Static validation | array |
Validon::ValidateList() |
Static validation via lists | array |
Validon::CheckLikeFieldsData() |
Static validation of similar fields | array |
🤝 Contributing
We welcome contributions to the project! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
Need help? We're here for you:
- Create an Issue
- Check the Wiki
- Email: [email protected]
🔗 Links
- Documentation
- Changelog
Validony - Making data validation simple and powerful! 🚀
All versions of validony with dependencies
ext-json Version *
ext-fileinfo Version *
ext-mbstring Version *