问题描述
有人知道在静态范围内使用Zend_Validate获取验证消息的方法吗?
Does anyone know of a way to get validation messages from using Zend_Validate in static scope?
Zend_Validate::is($value, $validator[0], $validator[2])
文档明确指出,获取消息不是一种选择: http://framework.zend.com/manual/en/zend.validate.introduction.html#zend.validate.introduction.static
The docs say explicitly that getting the messages isn't an option: http://framework.zend.com/manual/en/zend.validate.introduction.html#zend.validate.introduction.static
有点气disc,但我想知道是否有人知道Zend内的其他方法来从验证字符串中获取消息?
Slightly discouraging, but I was wondering if someone knew of any other methods that are inside Zend for getting messages from a validation string?
如果有兴趣的人,我正在关注有关在模型级别进行验证的精彩文章: http://www.cambraca.com/2011/03/validation-in-zend-framework-model.html
I'm following a great article about validating at the model level if anyone is interested: http://www.cambraca.com/2011/03/validation-in-zend-framework-model.html
感谢您的帮助,-塞思
Thanks for the help,-Seth
推荐答案
恐怕无法完成.可见,消息已附加到每个Validator对象 -您无法将它们附加到 class (除非您使用静态消息属性和静态setter/吸气剂,它将代替它使用.)
I'm afraid it just cannot be done. See, the messages are attached to each Validator object - you cannot attach them to class (unless you make your own implementation of the validation logic with static message properties and static setter/getter for it and will use it instead).
这篇关于Zend_Validate :: is()静态检查,获取验证消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!