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
How to install.
- Using composer
composer require logadapp/validator
- Include the generated autoload in your file, See index.php for example
<?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);
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