yii2.0 Rules Validation Rule Daquan

Source: Internet
Author: User
Required: Mandatory Value validation Property

[[' Field name '],required, ' requiredvalue ' = ' required value ', ' message ' = ' message ']; #说明: The alias of the Crequiredvalidator ensures that the attribute is not empty.

Email: Email Verification

[' email ', ' email ']; #说明: The alias of Cemailvalidator ensures that the value of the attribute is a valid e-mail address.

Match: Regular validation

[[' Field name '],match, ' pattern ' = ' regular expression ', ' message ' = ' hint message '];      [[' Field name '],match, ' not ' =>ture, ' pattern ' = ' regular expression ', ' message ' = ' hint message ']; /* Regular counter */#说明: Cregularexpressionvalidator alias, ensures that the attribute matches a regular expression.

URL: url

[' website ', ' url ', ' defaultscheme ' = ' http ']; #说明: The alias of the Curlvalidator ensures that the attribute is a valid path.

CAPTCHA: Verification Code

[' Verificationcode ', ' captcha ']; #说明: The alias of Ccaptchavalidator ensures that the value of the attribute is equal to the verification code shown CAPTCHA.

Safe: Secure

[' Description ', ' safe '];

Compare: Comparison

[' Age ', ' compare ', ' comparevalue ' and ' = ', ' operator ' and ' >= ']; #说明: CompareValue (compare constant value)-operator (comparison operator)  #说明: Ccomparevalidator alias, ensuring that the value of the attribute is equal to another attribute or constant.

Default: Defaults

[' Age ', ' Default ', ' value ' = null]; #说明: An alias for the cdefaultvaluevalidator that assigns a default value to the attribute.

exist: Presence

[' username ', ' exist ']; #说明: Cexistvalidator alias to ensure that the attribute value exists in the specified data table field.

File: Files

[' Primaryimage ', ' file ', ' extensions ' = [' png ', ' jpg ', ' gif '], ' maxSize ' + 1024*1024*1024]; #说明: The alias of the Cfilevalidator ensures that the feature contains the name of an uploaded file.

Filter: Filter

[[' username ', ' email '], ' filter ', ' filter ' = ' trim ', ' skiponarray ' = true]; #说明: Cfiltervalidator alias, use a filter conversion property.

In: Range

[' Level ', ' in ', ' range ' = [1, 2, 3]]; #说明: The alias of Crangevalidator ensures that the feature appears in the list of values for a subscription.

Unique: Uniqueness

[' username ', ' unique '] #说明: The alias of Cuniquevalidator ensures that the attribute is unique within the data table field.

Integer: Integers

[' Age ', ' Integer '];

Number: Numeric

[' Salary ', ' number '];

Double: dual-precision floating-point

[' Salary ', ' double '];

Date: Day

[[' From ', ' to '], ' date ';

String: Strings

[' username ', ' string ', ' length ' = [4, 24]];

Boolean: Whether it is a Boolean value

[' Field name ', ' Boolean ', ' truevalue ' = ' = ', ' falsevalue ' = False, ' strict ' = true]; #说明: Aliases for Cbooleanvalidator

Image: is a valid picture file

[' Primaryimage ', ' image ', ' extensions ' = ' png, jpg,jpeg ', ' minWidth ', ' = ', ' maxWidth ' = +, ' minheight ' = >, ' maxheight ' + 1000,]

We can leave a message to add the leak. Learn from each other

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