We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.



93.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.).


6.6k

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



6.6k

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