logadapp / validator
Request Validation library
v0.0.1
2023-05-08 19:41 UTC
Requires
- php: >=8.0
Requires (Dev)
- phpmd/phpmd: ^2.13
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
README
LogadApp\Validator
About The Project
Features
- Simple to use
- Supports underscores and camelcase (file_size or fileSize)
- Easy to create your own rules
- File validation
- Min\Max length validation
- Email validation
- File size validation
- Conditional requirements
- Similar to Laravel's validation feature
- Inspired by Rakit\Validation
Installation
How to install.
- Using composer
composer require logadapp/validator
- Include the generated autoload in your file, See index.php for example
Usage
<?php use LogadApp\Validator\Validation; require('vendor/autoload.php'); $validator = new Validation; $rules = [ 'test' => 'required|numeric|max:10|min:5', 'text' => 'required|maxLength:5|minLength:3', 'email' => 'required|email', 'type' => 'required|in:user,admin', 'name' => 'requiredIf:type,user,admin', 'profilePic' => 'file|requiredIf:type,user,admin|fileSize:10KB|fileType:jpg,png,jpeg', ]; $validator->make($_POST, $_FILES, $rules); $validator->validate();
OR Validate directly
$validator->validate($_POST, $_FILES, $rules);
Built With
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch
- Commit your Changes
- Push to the Branch
- Open a Pull Request