S
S
Sergey2015-09-22 20:20:02
Node.js
Sergey, 2015-09-22 20:20:02

How to do dynamic validation?

I would like to register users and, depending on their status "just a user" or "professional", validate the fields. Those. if "just a user", then only "email", "password" is enough on the server, and if "professional", then these fields are validated (necessary) + more (also necessary). Does this validation need to be somehow specially described in the model (Mongoose) or is it all done at the Express controller level? type, "if such and such, then the data goes into the model such and such." Is there any example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Spiridonov, 2015-09-22
@customtema

Isn't it easier to make two different methods?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question