https://github.com/mkakpabla/form-validation-php
A simple validator in php
https://github.com/mkakpabla/form-validation-php
php validation validation-errors validation-library validation-messages validation-rules
Last synced: 10 days ago
JSON representation
A simple validator in php
- Host: GitHub
- URL: https://github.com/mkakpabla/form-validation-php
- Owner: mkakpabla
- Created: 2019-09-14T10:11:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-20T17:30:23.000Z (about 6 years ago)
- Last Synced: 2023-03-25T19:54:39.441Z (almost 3 years ago)
- Topics: php, validation, validation-errors, validation-library, validation-messages, validation-rules
- Language: PHP
- Homepage:
- Size: 51.8 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/mkakpabla/form-validation-php)
# Zen Validation - PHP Validation Library
## Features
* API like Laravel validation.
* Array validation.
* Custom validation messages.
## Requirements
* PHP 7.2 or higher
* Composer for installation
## Quick Start
#### Installation
```bash
composer require "mkakpabla/validation"
```
#### Usage
Examples :
```php
'required|notEmpty',
'slug' => 'required|slug',
'content' => 'required|text'
]);
$validator->validate();
if(!$validator->isValid()) {
var_dump($validator->errors());
} else {
// Formulaire valide
// Traitements
}
```
#### Custom Messages for Validator
```php
'required',
]);
$validator->addErrorsMessages([
'title.required' => "le titre est obligatoire"
]);
$validator->validate();
````
## Validation Rules
* `required` - Field is required
* `email` - Field must be email
* `notEmpty` - Field did not be empty
* `alpha` - Content of field must be alphabetic
* `alphaNum` - Content of field must be alphanumeric
* `integer` - Must be integer number
* `text` - Field must be a text
* `datetime` - Field must be a datetime
* `time` - Field must be a time
* `date` - Field must be a date
* `slug` - Field must be a slug
* `confirm` - Field must be a same as another field
* `min:number` - The field under this rule must have a size biger or equal than the given number
* `max:number` - The field under this rule must have a size lower or equal than the given number
* `between:min,max` - The field under this rule must have a size between min and max params