B
B
BonBon Slick2017-12-10 19:31:24
symfony
BonBon Slick, 2017-12-10 19:31:24

Validating Request $request?

It is necessary to validate in different methods in different ways, and not to be indicated in the annotations, there are already too many of them.
Do something in the style of Laravel
https://laravel.com/docs/5.5/validation#creating-f...
It will also be necessary to add a bunch of rules, because apparently Symfony finally doesn’t care how validation and authorization are done there , let others sculpt everything themselves from scratch, or bundles and packages.
That is, to accept not a Request, but an already checked DoSmthRequest.

public function registerNewUser(CreqteNewUserRequest $request)

Without any additional calls inside the method to validate the data. By type array, and we sculpt there new NotNull() and a dozen more rules
'some_field_goes_here' => new Rulle(), new Rulle(), new Rulle(), new Rulle(), new Rulle(),  new Rulle(), new Rulle(), new Rulle(), new Rulle(), new Rulle(),
looks bad, right?
And if you add custom ones...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2017-12-10
@BonBonSlick

Request is an HTTP request wrapper. An HTTP request may not be valid if it is incorrectly composed: incorrect header value, etc., it has nothing to do with business logic (the email is not correctly specified in the form, etc.). In my opinion, what is done in Laravel (if this is true, I emphasize that I do not know it!) Is madness.
I recommend looking at the validation groups, maybe this is what you need: How to Apply only a Subset of all Your Validation ... .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question