Permalink
Browse files

Error messages related to array value case changed.

  • Loading branch information...
1 parent 692390f commit f635a4c8a451360df956bfd69af7e63603cc4b74 @resurtm resurtm committed Mar 10, 2013
@@ -76,7 +76,7 @@ protected function validateAttribute($object,$attribute)
if(is_array($value))
{
// https://github.com/yiisoft/yii/issues/1955
- $this->addError($object,$attribute,Yii::t('yii','{attribute} must not have array value.'));
+ $this->addError($object,$attribute,Yii::t('yii','{attribute} is invalid.'));
return;
}
@@ -81,7 +81,8 @@ protected function validateAttribute($object,$attribute)
if(is_array($value))
{
// https://github.com/yiisoft/yii/issues/1955
- $this->addError($object,$attribute,Yii::t('yii','{attribute} must not have array value.'));
+ $message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be a number.');
+ $this->addError($object,$attribute,$message);
return;
}
if($this->integerOnly)
@@ -48,12 +48,10 @@ protected function validateAttribute($object,$attribute)
return;
if($this->pattern===null)
throw new CException(Yii::t('yii','The "pattern" property must be specified with a valid regular expression.'));
- if(is_array($value))
- {
- // https://github.com/yiisoft/yii/issues/1955
- $this->addError($object,$attribute,Yii::t('yii','{attribute} must not have array value.'));
- }
- elseif((!$this->not && !preg_match($this->pattern,$value)) || ($this->not && preg_match($this->pattern,$value)))
+ // reason of array checking explained here: https://github.com/yiisoft/yii/issues/1955
+ if(is_array($value) ||
+ (!$this->not && !preg_match($this->pattern,$value)) ||
+ ($this->not && preg_match($this->pattern,$value)))
{
$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} is invalid.');
$this->addError($object,$attribute,$message);
@@ -83,7 +83,7 @@ protected function validateAttribute($object,$attribute)
if(is_array($value))
{
// https://github.com/yiisoft/yii/issues/1955
- $this->addError($object,$attribute,Yii::t('yii','{attribute} must not have array value.'));
+ $this->addError($object,$attribute,Yii::t('yii','{attribute} is invalid.'));
return;
}
@@ -86,7 +86,7 @@ protected function validateAttribute($object,$attribute)
if(is_array($value))
{
// https://github.com/yiisoft/yii/issues/1955
- $this->addError($object,$attribute,Yii::t('yii','{attribute} must not have array value.'));
+ $this->addError($object,$attribute,Yii::t('yii','{attribute} is invalid.'));
return;
}
@@ -138,6 +138,5 @@ public function testArrayValue()
$model->name = array('test_name');
$this->assertFalse($model->validate());
$this->assertTrue($model->hasErrors('name'));
- $this->assertSame(array('Name must not have array value.'),$model->getErrors('name'));
}
}
@@ -29,7 +29,6 @@ public function testMin()
$model4->string1=array('1234567890');
$model4->validate(array('string1'));
$this->assertTrue($model4->hasErrors('string1'));
- $this->assertSame(array('String1 must not have array value.'),$model4->getErrors('string1'));
}
public function testMax()
@@ -59,7 +58,6 @@ public function testMax()
$model4->string2=array('1234567890');
$model4->validate(array('string2'));
$this->assertTrue($model4->hasErrors('string2'));
- $this->assertSame(array('String2 must not have array value.'),$model4->getErrors('string2'));
}
public function testIs()
@@ -96,6 +94,5 @@ public function testIs()
$model5->string3=array('1234567890');
$model5->validate(array('string3'));
$this->assertTrue($model5->hasErrors('string3'));
- $this->assertSame(array('String3 must not have array value.'),$model5->getErrors('string3'));
}
}
@@ -138,6 +138,5 @@ public function testArrayValue()
$model->name = array('test_name');
$this->assertFalse($model->validate());
$this->assertTrue($model->hasErrors('name'));
- $this->assertSame(array('Name must not have array value.'),$model->getErrors('name'));
}
}

0 comments on commit f635a4c

Please sign in to comment.