Vasaris 2011
Yii framework validators
Sveiki,
ištraukiau pagrindinius validatorius, kurie yra Yii frameworke:
Validation rules reference
-
boolean
: CBooleanValidator, validates that the attribute value is either trueValue or falseValue.allowEmpty
, whether the attribute value can be null or empty.falseValue
, the value representing false status.strict
, whether the comparison to trueValue and falseValue is strict.trueValue
, the value representing true status.
-
captcha
: CCaptchaValidator, validates that the attribute value is the same as the verification code displayed in the CAPTCHA.allowEmpty
, whether the attribute value can be null or empty.captchaAction
, ID of the action that renders the CAPTCHA image.caseSensitive
, whether the comparison is case sensitive.
-
compare
: CCompareValidator, compares the specified attribute value with another value and validates if they are equal.allowEmpty
, whether the attribute value can be null or empty.compareAttribute
, the name of the attribute to be compared with.compareValue
, the constant value to be compared with.operator
, the operator for comparison.strict
, whether the comparison is strict (both value and type must be the same.
-
default
: CDefaultValueValidator, sets the attributes with the specified value. It does not do validation. Its existence is mainly to allow specifying attribute default values in a dynamic way.setOnEmpty
, whether to set the default value only when the attribute value is null or empty string.value
, the default value to be set to the specified attributes.
-
email
: CEmailValidator, validates that the attribute value is a valid email address.allowEmpty
, whether the attribute value can be null or empty.allowName
, whether to allow name in the email address.checkMX
, whether to check the MX record for the email address.checkPort
, whether to check port 25 for the email address.fullPattern
, the regular expression used to validate email addresses with the name part.pattern
, the regular expression used to validate the attribute value.
-
exist
: CExistValidator, validates that the attribute value exists in a table.allowEmpty
, whether the attribute value can be null or empty.attributeName
, the ActiveRecord class attribute name that should be used to look for the attribute value being validated.className
, the ActiveRecord class name that should be used to look for the attribute value being validated.criteria
, additional query criteria.
-
file
: CFileValidator, verifies if an attribute is receiving a valid uploaded file.allowEmpty
, whether the attribute requires a file to be uploaded or not.maxFiles
, the maximum file count the given attribute can hold.maxSize
, the maximum number of bytes required for the uploaded file.minSize
, the minimum number of bytes required for the uploaded file.tooLarge
, the error message used when the uploaded file is too large.tooMany
, the error message used if the count of multiple uploads exceeds limit.tooSmall
, the error message used when the uploaded file is too small.types
, a list of file name extensions that are allowed to be uploaded.wrongType
, the error message used when the uploaded file has an extension name that is not listed among extensions.
-
filter
: CFilterValidator, transforms the data being validated based on a filter.filter
, the filter method.
-
in
: CRangeValidator, validates that the attribute value is among the list (specified via range).allowEmpty
, whether the attribute value can be null or empty.range
, list of valid values that the attribute value should be among.strict
, whether the comparison is strict (both type and value must be the same).
-
length
: CStringValidator, validates that the attribute value is of certain length.allowEmpty
, whether the attribute value can be null or empty.encoding
, string encoding.is
, exact length.max
, maximum length.min
, minimum length.tooLong
, user-defined error message used when the value is too short.tooShort
, user-defined error message used when the value is too long.
-
numerical
: CNumberValidator, validates that the attribute value is a number.allowEmpty
, whether the attribute value can be null or empty.integerOnly
, whether the attribute value can only be an integer.max
, upper limit of the number.min
, lower limit of the number.tooBig
, user-defined error message used when the value is too big.tooSmall
, user-defined error message used when the value is too small.
-
match
: CRegularExpressionValidator, validates that the attribute value matches to the specified regular expression.allowEmpty
, whether the attribute value can be null or empty.pattern
, the regular expression to be matched with.
-
required
: CRequiredValidator, validates that the specified attribute does not have null or empty value.requiredValue
, the desired value that the attribute must have.strict
, whether the comparison to requiredValue is strict.
-
safe
: CSafeValidator, marks the associated attributes to be safe for massive assignments. -
type
: CTypeValidator, verifies if the attribute is of the type specified by type. (integer, float, string, date, time, datetime)allowEmpty
, whether the attribute value can be null or empty.dateFormat
, the format pattern that the date value should follow.datetimeFormat
, the format pattern that the datetime value should follow.timeFormat
, the format pattern that the time value should follow.type
, the data type that the attribute should be.
Example of time rule;
array('org_starttime, org_finishtime', 'type', 'type'=>'time', 'timeFormat'=>'hh:mm'),
-
unique
: CUniqueValidator, validates that the attribute value is unique in the corresponding database table.allowEmpty
, whether the attribute value can be null or empty.attributeName
, the ActiveRecord class attribute name that should be used to look for the attribute value being validated.caseSensitive
, whether the comparison is case sensitive.className
, the ActiveRecord class name that should be used to look for the attribute value being validated.criteria
, additional query criteria.
By default, CUniqueValidator works with a single attribute that's presumed to be unique across the whole model table, but it can work with multi-attribute unique constraints as well. See CUniqueValidator::c2215 for an example.
-
unsafe
: CUnsafeValidator, marks the associated attributes to be unsafe so that they cannot be massively assigned. -
url
: CUrlValidator, validates that the attribute value is a valid http or https URL.allowEmpty
, whether the attribute value can be null or empty.pattern
, the regular expression used to validates the attribute value.
Kur galima skaityti dokumentus
http://www.docstoc.com/
http://www.scribd.com/
Kur dar?
Apie
Čia rasite kažką įdomaus, kas susiję su manimi ir mano veikla.
Paskutinės galerijos
Archyvas
- Birželis 2019 (1)
- Liepa 2017 (1)
- Gruodis 2016 (18)
- Liepa 2016 (1)
- Rugpjūtis 2011 (16)
- Rugsėjis 2011 (17)
- Gegužė 2011 (13)
- Liepa 2011 (13)
- Spalis 2010 (2)
- Lapkritis 2010 (1)
- Vasaris 2011 (3)
- Spalis 2011 (13)
- Birželis 2011 (2)
- Liepa 2010 (1)
- Kovas 2010 (1)
- Balandis 2010 (1)
- Balandis 2011 (1)
- Sausis 2011 (1)
- Lapkritis 2011 (2)
- Gruodis 2011 (1)