This commit is contained in:
Qiang Xue
2011-07-22 23:08:40 -04:00
parent 0c7a75bef7
commit af593aad5e
16 changed files with 244 additions and 357 deletions

View File

@@ -12,7 +12,7 @@ namespace yii\validators;
/**
* RegularExpressionValidator validates that the attribute value matches the specified [[pattern]].
*
* If [[not]] is set true, the validator will ensure the attribute value do NOT match the [[pattern]].
* If the [[not]] property is set true, the validator will ensure the attribute value do NOT match the [[pattern]].
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
@@ -64,12 +64,13 @@ class RegularExpressionValidator extends Validator
public function clientValidateAttribute($object, $attribute)
{
if ($this->pattern === null) {
throw new \yii\base\Exception(Yii::t('yii', 'The "pattern" property must be specified with a valid regular expression.'));
throw new \yii\base\Exception('The "pattern" property must be specified with a valid regular expression.');
}
$message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} is invalid.');
$message = strtr($message, array(
'{attribute}' => $object->getAttributeLabel($attribute),
'{value}' => $object->$attribute,
));
$pattern = $this->pattern;