andersao / andersao/l5-repository

Why should we validate in creating method?

Offen
#736 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
4.2k
Forks
880
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I'm trying to understand the decision of call the validator in create method:

https://github.com/andersao/l5-repository/blob/master/src/Prettus/Repository/Eloquent/BaseRepository.php#L619

So far as I understand, is not the responsibility of create method to validate something.
And if we already call this:
```
$this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE);
```
In the controller action, why should we repeat the same in create method?

In my point of view that's annoying, and I can't change the data after the validation in controller and before the create method.

Well, just clarify my blur point of view please.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.