Skip to content

Commit e4a7dab

Browse files
author
Sam Rapaport
committed
Rename validator directory to Validators.
Rename directory `app/Validation` to `app/Validators` to be more consistent with the naming conventions of Laravel application directories.
1 parent 15e426d commit e4a7dab

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@ Then add the service provider to your providers array in `config/app.php`:
3131

3232
`Samrap\Validation\ValidationServiceProvider::class`
3333

34-
Finally, the base `Validator` class needs to be published to a new `app/Validation` directory. This can be done using the `vendor:publish` command:
34+
Finally, the base `Validator` class needs to be published to a new `app/Validators` directory. This can be done using the `vendor:publish` command:
3535

3636
`php artisan vendor:publish`
3737

3838
### Usage
3939
---
40-
All validators reside in the `app/Validation` directory and extend the abstract class `App\Validation\Validator`. There should be one validator class per model. For example, the validator for a `User` model could be called `UserValidator`.
40+
All validators reside in the `app/Validators` directory and extend the abstract class `App\Validators\Validator`. There should be one validator class per model. For example, the validator for a `User` model could be called `UserValidator`.
4141

4242
Laravel Validation provides a useful artisan command for generating new validators on the fly. Let's create a validator for our `User` model and define some rules:
4343

4444
`php artisan make:validator UserValidator`
4545

46-
This will create a new `UserValidator` class in the `app/Validation` directory that looks like this:
46+
This will create a new `UserValidator` class in the `app/Validators` directory that looks like this:
4747

4848
```
4949
<?php
5050
51-
namespace App\Validation;
51+
namespace App\Validators;
5252
53-
use App\Validation\Validator;
53+
use App\Validators\Validator;
5454
5555
class UserValidator extends Validator
5656
{
@@ -81,7 +81,7 @@ Great! We now have a validator class named `UserValidator` with the rules we int
8181

8282
First, we will want to import this class into our controller:
8383

84-
`use App\Validation\UserValidator`
84+
`use App\Validators\UserValidator`
8585

8686
Now, let's validate a POST request for the controller's `store` method:
8787

@@ -126,7 +126,7 @@ In this case, we are adding a rule for a `name` field, which will be merged with
126126
##### Multiple Rulesets
127127
Laravel Validation expects a `rules` property on your validator class, but it is possible to define additional properties and use those in specific cases. You may have different requirements when updating a record vs storing, or have unique rules if a user is of a specific role.
128128

129-
Let's define an `updating` property on the `App\Validation\UserValidator` class with specific rules for updating a user:
129+
Let's define an `updating` property on the `App\Validators\UserValidator` class with specific rules for updating a user:
130130

131131
```
132132
protected $updating = [

app/Validation/Validator.php renamed to app/Validators/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Validation;
3+
namespace App\Validators;
44

55
use Samrap\Validation\Validator as BaseValidator;
66

src/Commands/ValidatorMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ protected function getStub()
4545
*/
4646
protected function getDefaultNamespace($rootNamespace)
4747
{
48-
return $rootNamespace.'\Validation';
48+
return $rootNamespace.'\Validators';
4949
}
5050
}

0 commit comments

Comments
 (0)