https://github.com/lakshmaji/validators
https://github.com/lakshmaji/validators
laravel validator validators
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lakshmaji/validators
- Owner: lakshmaji
- Created: 2018-01-28T16:45:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T11:17:23.000Z (almost 5 years ago)
- Last Synced: 2025-02-10T20:56:40.924Z (about 1 year ago)
- Topics: laravel, validator, validators
- Language: PHP
- Size: 1.14 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Validators
>### What it is
- Validator helpers for Laravel Validation.
>### Version
1.0.1
>### Sample

>### Compatibility
**Laravel version** | **Validators version**
-------- | ---
5.5 | 1.0.1
5.4 <= | ? (not sure)
>### Installation
- This package is available through composer installation
```bash
composer require lakshmaji/validators
```
- Try updating the application with composer (autloading class namespaces but not mandatory :wink: )
```bash
composer dump-autoload
```
>### Configurations
- Publish the configuration file.
```bash
php artisan vendor:publish
```
- The configuration file will be published to your application **config** directory with the name * validators.php*.
- Configure the required validator namespaces and validator class paths.
- An example configuration file (validators.php).
```php
'App\Validators',
/*
|--------------------------------------------------------------------------
| Validator path
|--------------------------------------------------------------------------
|
| The path to the validators folder.
|
*/
'validator_path' => 'app' . DIRECTORY_SEPARATOR . 'MyValidators' . DIRECTORY_SEPARATOR . 'MyRules',
];
```
>### Generating Validator
- Issue the following command in terminal
```bash
php artisan make:validator CreateVehicle
```
- This will generate the following class and located the path configured in validators.php
```php
'required',
'model' => 'required'
];
/**
* @var array
*/
protected $messages = [
'model.required' => 'Please specify the model number',
];
}
// end of CreateVehicleValidator class
```
>### Using it in action
```php
validator = $validator;
$this->request = $request;
}
public function store() {
$payload = $this->request->all();
// validate here
if($this->validator->with($payload)->passes()) {
// validation succedded
} else {
$errors = $this->validator->formatErrorMessages();
}
}
```
>### MISCELLANEOUS
- After installing package you find the **artisan** commands in your project
```bash
php artisan list
```
- OR
```bash
php artisan help make:validator
```
>### Thanks to
[@parthshukla] (https://github.com/parthshukla)
>### LICENSE
[MIT](https://opensource.org/licenses/MIT)