V
V
vladislav31012021-04-26 00:01:49
Design patterns
vladislav3101, 2021-04-26 00:01:49

What is the purpose of the MVC controller pattern?

Interested in the question of where to validate the data that came from the front? The same registration form, let's say we receive empty data, email validation, password length check, where should I check this in the model or controller?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vladislav3101, 2021-04-26
@vladislav3101

Found the answer after 1 hour, went through a lot of garbage on the forums. Answer: in models! I explain: the model can be used in different places and it makes no sense to write the same checks in controllers. Let's allow a check for emptiness in the sent data, it's better to check it once in models than to write the same thing in different controllers. The controller will only receive a response from the model and give it to the client in the desired form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question