use Phalcon\Mvc\Model\Validator\StringLength as StringLengthValidator;
class Subscriptors extends Phalcon\Mvc\Model
{
public function validation()
{
$this->validate(new StringLengthValidator(array(
'field' => 'name_last',
'max' => 10,
'min' => 2,
'messageMaximum' => 'We don\'t like really long names',
'messageMinimum' => 'We want more than just their initials'
)));
if ($this->validationHasFailed() == true) {
return false;
}
}
}
This code does not run properly. 'messageMaximum' 'messageMinimum' can not show their own definitions.
The following data is displayed 。 It is not my definitions.
array (size=1)
0 =>
object(Phalcon\Mvc\Model\Message)[57]
protected '_type' => string 'TooLong' (length=7)
protected '_message' => string 'Value of field 'name' exceeds the maximum 10 characters' (length=55)
protected '_field' => string 'name' (length=4)
protected '_model' => null