https://github.com/morilog/validator
Laravel Validator with multiple scenarios
https://github.com/morilog/validator
laravel scenario validation validator
Last synced: 3 months ago
JSON representation
Laravel Validator with multiple scenarios
- Host: GitHub
- URL: https://github.com/morilog/validator
- Owner: morilog
- License: gpl-3.0
- Created: 2015-10-05T16:58:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T12:39:06.000Z (over 5 years ago)
- Last Synced: 2024-04-29T14:20:55.181Z (about 1 year ago)
- Topics: laravel, scenario, validation, validator
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 5
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validator
Simple validator library for Laravel framework with multiple scenarios. By using this package, you write your validator once
and use every where and moderate your Domain rules easily.### Installation
Use composer:
```bash
composer require laratalks/validator
```### Usage
Your valdiation classes must extends `Laratalks\Valdiator\AbstarctValdiator` :
```php
['required'],
'email' => ['required', 'email'],
'home_page' => ['required', 'url']
];protected $activationRules = [
'id' => ['required', 'exists:users'],
'token' => ['required', 'min:64']
];protected $anotherScenarioRules = [
'key1' => ['rule1', 'rule2'],
'key2' => ['rule1', 'rule2']
];
}
```You must inject validatio in your methods or controller `__construct` method to using it:
```php
setScenario('registration')
->validate($request->all());
} catch (ValidationException $e) {
// catch errors
return $e->getErrors();
}
}
}
```