Set form validation method in model

Source: Internet
Author: User

The model class defines the validation factor format supported by the $_validate property: Format: Array (validation field, validation rule, error prompt, validation condition, additional rule, validation time).

Validation criteria:

(1) Model::exists_to_vailidate or 0 existence field is verified (default)
(2) Model::must_to_validate or 1 must be verified
(3) Verify when model::value_to_vailidate or 2 value is not empty


There are additional validation rule syntax: Mate validation rules can be used

(1) The Regex uses regular validation to indicate that the validation rule defined earlier is a regular expression (default)
(2) Function validation is used, and the validation rule defined above is a functional name
(3) Callback use method validation, the previously defined validation rule is a method of the current model class
(4) Confirm Verify that the two fields in the form are the same, the validation rule defined above is a field name
(5) Equal verify that the value is equal to a value that is defined by the previous validation rule
(6) in to verify that the validation rule defined above must be an array within a range
(7) Unique authentication, the system will query the database based on the current value of the field to determine whether the same value exists
Require field must, email mailbox, URL URL address, currency currency, number

Set form validation method in model

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.