You need change this in the model
public function rules()
{
return [
['image', 'required','message'=>'It is required'],
];
}
This is for if it is required, but you could put your function, for example:
public function rules()
{
return [
['image', 'validateImage',]
];
}
public function validateImage($attribute, $params)
{
if (...) {
$this->addError($attribute, 'Incorrect image.');
}
}
}
In the images I use this :
public function rules()
{
return [['file', 'file','skipOnEmpty' => false,
'uploadRequired' => '', //Error
'maxSize' => 1024*1024*1, //1 MB
'tooBig' => '', //Error
'minSize' => 10, //10 Bytes
'tooSmall' => '', //Error
'maxFiles' => 10,
'tooMany' => '', //Error
],];
}
but I think that you dont want this
The errors are for each atribute in the model, if you have two attributes in the model you have two errors,two validations differents ,
you can change all labels for the atributes in the model:
public function attributeLabels()
{
return [
'image' => 'The image',
'name' => 'The name',
];
}