Is there a way for the controller to be loosely coupled with the validation () method in the model Phalcon

Source: Internet
Author: User
Is that my model has defined the validation () method, so the controller calls create (), save (), update () and other methods before the database will automatically go validation () This method, there is no way to let him not go, Skip this method.

Reply content:

Is that my model has defined the validation () method, so the controller calls create (), save (), update () and other methods before the database will automatically go validation () This method, there is no way to let him not go, Skip this method.

1, in the expansion has been written dead, can not skip the beforevalidation, beforevalidationonxx events.
2, generally only write common data format validation there, it is not recommended to involve the validation of business logic also thrown in.
3, the best practice is that generally involves the business logic validation is directly in transaction script or domain object, aside from TS, you can not directly use the Phalcon default active record as a domain object, You also need to abstract out domain Object and finally pass repository as the façade.

Our company this is to be verified independently. The controller layer is called before the data is validated.

  • 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.