我正在尝试自定义Value is required and can't be empty
zf2 中的默认错误消息“”
我正在使用以下代码在 inputfilter 的验证器中添加自定义默认错误消息
$inputFilter->add($factory->createInput(array(
'name' => 'username',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 4,
'max' => 20,
'messages' => array(
'isEmpty' => 'Please enter User Name between 4 to 20 character!'
),
),
),
),
)));
但我收到以下错误。
Zend\Validator\Exception\InvalidArgumentException
File:
/home/website/vendor/zendframework/zendframework/library/Zend/Validator/AbstractValidator.php:220
Message:
No message template exists for key 'isEmpty'
我做错了什么?