Is there a way in phalcon to loosely couple the validation () method in the Controller and Model?

Source: Internet
Author: User
That is, the validation () method has been defined in my Model. Therefore, the controller will automatically go through validation () before saving the methods such as create (), save (), and update () to the database () is there a way for him to skip this method. That is, the validation () method has been defined in my Model. Therefore, the controller will automatically go through validation () before saving the methods such as create (), save (), and update () to the database () is there a way for him to skip this method.

Reply content:

That is, the validation () method has been defined in my Model. Therefore, the controller will automatically go through validation () before saving the methods such as create (), save (), and update () to the database () is there a way for him to skip this method.

1. The events beforeValidation and beforeValidationOnXX cannot be skipped.
2. Generally, you only need to write the Common Data Format verification to it. We do not recommend that you throw the verification involving the business logic into it.
3. The best practice is that the verification that involves business logic is directly in Transaction Script or Domain Object. Aside from TS, you cannot directly use Phalcon's default Active Record as a Domain Object, you also need to abstract the Domain Object and use repository as the facade ..

Our company will verify the data only when the Controller layer calls it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.