A
A
Anton V.2021-01-21 22:03:57
Laravel
Anton V., 2021-01-21 22:03:57

Why is Middleware TrimStrings enabled by default in Laravel?

Good afternoon!
Perhaps someone can tell me why Middleware TrimStrings is enabled by default in Laravel?

I understand that it is needed in order to trim all input parameters...
but perhaps there is a reason why it is by default

.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2021-01-21
@ivinnic

This is an old pain point with spaces at the end and at the beginning (more rarely) entered by users in different fields.
The problem was so common that whitespace trimming was almost always in the code. Therefore, we added such functionality by default, at the same time, by the way, with setting empty strings to null. Which also increased convenience.
If necessary, you can write exceptions there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question