English 中文(简体)
Zend_Validate_Date Just don t work appropriate
原标题:Zend_Validate_Date just doesn t work properly

Zend_Validate_Date。 简单地说,就是不适当地工作。 例如:

$validator = new Zend_Validate_Date(array( format  =>  yyyy ));

This is a simple validator that should only accept a four digit year, yet $validator->isValid( 1/2/3 ) returns true! Really, Zend?

或如何做到这一点:

$otherValidator = new Zend_Validate_Date(array( format  =>  mm/dd/yyyy ));

即便有上述法典,$otherValidator->isValid() ∗∗∗∗∗

I m 采用Zentd Framework 1.11.9。 这难道只是我,还是真的可怕的验证类别? (UPDATE: 换言之,与我的法典有点错误,还是应该提出这种建议吗?)

问题回答

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
);

希望这将有助于其他人。 请注意,我只想把冲突 as为分裂者,而不是 do或 da。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...