N
N
NubasLol2018-10-29 11:03:12
Laravel
NubasLol, 2018-10-29 11:03:12

How to properly normalize query data?

I use my Request class in Laravel to implement the validation logic. Well, the question arose of how to pre-process the request data correctly. For example, put a phone number in a single format.
Should I write this logic in the constructor or somewhere else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-10-29
@NubasLol

Just like it says in the documentation .
Upd. At the urgent request of the author, who does not know enemy dialects and does not plan to study them, I am writing in RUSSIAN:
out of the box, Laravel has middleware TrimStringsand ConvertEmptyStringsToNull, which modify the request data, normalizing them. Therefore, by analogy, you can create a mildware that normalizes the phone specifically and connects it to the routes you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question