すべてのバリデーターの最後のパラメーターは配列にすることができます。渡すことができるパラメーターの 1 つに「messages」があります。これは、各エラーを表すバリデーター固有の定数の配列と、エラー メッセージの文字列です。バリデータ クラス (Zend/Validate/File/ImageSize.php など) を調べると、エラー コードのリストを取得できます。あなたの場合、これらは次のようになります。
$file = new Zend_Form_Element_File('file', array(
'required' => false, //we will add this as a custom validator so we can over-ride the error message
'MaxFileSize' => 4194304,
'validators' => array(
array('NotEmpty', true, array('messages' => array('isEmpty' => "Your error message here")))
array('Count', false, array(count => 1, 'messages' => array('fileCountTooFew' => "Too few files, minimum '%min%' are expected but '%count%' are given", 'fileCountTooMany' => "Too many files, maximum '%max%' are allowed but '%count%' are given"))),
array('Size', false, array('size' => 4194304, 'messages'=> array('fileSizeTooBig' => "", 'fileSizeTooSmall' => "", 'fileSizeNotFound' => ""))),
array('Extension', false, array('extension' => 'gif,jpg,png', 'messages' => array('fileExtensionFalse' => "", 'fileExtensionNotFound' => ""))),
array('ImageSize', false, array('minwidth' => 40,
'minheight' => 40,
'maxwidth' => 90,
'maxheight' => 90,
'messages' => array(
'fileImageSizeWidthTooBig' => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected",
'fileImageSizeWidthTooSmall' => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected",
'fileImageSizeHeightTooBig' => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected",
'fileImageSizeHeightTooSmall' => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected",
'fileImageSizeNotDetected' => "The size of image '%value%' could not be detected",
'fileImageSizeNotReadable' => "File '%value%' can not be read",
)
)
)
)
)
);