Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Verification should be written in the form or in the model.

Verification should be written in the form or in the model?

Is there any good specifications recommended?

If you are gonna use phalcon forms - then in form, if not - then in model.



62.7k
Accepted
answer

As @Woljciech said, if you can validate data before passign to model it will be the best. This way you do not hit the database layer, which in large applications could slow you down.

Basically what I do is:

  1. Validate forms with javascript before sending to server;

  2. Use Phalcon forms again to validate the data (since client based validation can be exploited);

  3. Pass data to model to save (here you can also have validation for unique columns e.t.c.).



2.3k

Thank you very much.

If you don't have more questions and you think we answered your question, please mark @Wojciech's answer to solve the thread for others :P



2.3k

OK.

If you don't have more questions and you think we answered your question, please mark @Wojciech's answer to solve the thread for others :P