Zend_Validate_Date just doesn't work properly

爱⌒轻易说出口 提交于 2019-12-05 10:42:26

As the comments above say, apparently there's a bug with this class. Here is the workaround I came up with, using Zend_Validate_Regex:

$validator = new Zend_Validate_Regex(
    array('pattern' => '/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/')
);
$validator->setMessage(
    "Date does not match the format 'mm/dd/yyyy'",
    Zend_Validate_Regex::NOT_MATCH
);

Hopefully that will help someone else. Please note that I only want slashes as separator, not dots or dashes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!