PHP Class yii\validators\StringValidator

Note, this validator should only be used with string-typed attributes.
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends Validator
Exibir arquivo Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$encoding the encoding of the string value to be validated (e.g. 'UTF-8'). If this property is not set, [[\yii\base\Application::charset]] will be used.
$length specifies the length limit of the value to be validated. This can be specified in one of the following forms: - an integer: the exact length that the value should be of; - an array of one element: the minimum length that the value should be of. For example, [8]. This will overwrite [[min]]. - an array of two elements: the minimum and maximum lengths that the value should be of. For example, [8, 128]. This will overwrite both [[min]] and [[max]].
$max maximum length. If not set, it means no maximum length limit.
$message user-defined error message used when the value is not a string.
$min minimum length. If not set, it means no minimum length limit.
$notEqual user-defined error message used when the length of the value is not equal to [[length]].
$tooLong user-defined error message used when the length of the value is greater than [[max]].
$tooShort user-defined error message used when the length of the value is smaller than [[min]].

Public Methods

Method Description
clientValidateAttribute ( $model, $attribute, $view )
init ( )
validateAttribute ( $model, $attribute )

Protected Methods

Method Description
validateValue ( $value )

Method Details

clientValidateAttribute() public method

public clientValidateAttribute ( $model, $attribute, $view )

init() public method

public init ( )

validateAttribute() public method

public validateAttribute ( $model, $attribute )

validateValue() protected method

protected validateValue ( $value )

Property Details

$encoding public_oe property

the encoding of the string value to be validated (e.g. 'UTF-8'). If this property is not set, [[\yii\base\Application::charset]] will be used.
public $encoding

$length public_oe property

specifies the length limit of the value to be validated. This can be specified in one of the following forms: - an integer: the exact length that the value should be of; - an array of one element: the minimum length that the value should be of. For example, [8]. This will overwrite [[min]]. - an array of two elements: the minimum and maximum lengths that the value should be of. For example, [8, 128]. This will overwrite both [[min]] and [[max]].
See also: tooShort for the customized message for a too short string.
See also: tooLong for the customized message for a too long string.
See also: notEqual for the customized message for a string that does not match desired length.
public $length

$max public_oe property

maximum length. If not set, it means no maximum length limit.
See also: tooLong for the customized message for a too long string.
public $max

$message public_oe property

user-defined error message used when the value is not a string.
public $message

$min public_oe property

minimum length. If not set, it means no minimum length limit.
See also: tooShort for the customized message for a too short string.
public $min

$notEqual public_oe property

user-defined error message used when the length of the value is not equal to [[length]].
public $notEqual

$tooLong public_oe property

user-defined error message used when the length of the value is greater than [[max]].
public $tooLong

$tooShort public_oe property

user-defined error message used when the length of the value is smaller than [[min]].
public $tooShort