Edit report at
http://pear.php.net/bugs/bug.php?id=16906&edit=1ID: 16906
Updated by:
[email protected]Reported By: hm2k at php dot net
Summary: no email validation like HTML_Qu
Status: Open
Type: Feature/Change Request
Package: HTML_QuickForm2
Package Version: 0.3.0
PHP Version: Irrelevant
Roadmap Versions:
New Comment:
My advise would be to impliment it from HTML_QuickForm and improve.
Implementing filter_var, while better than nothing isn't exactly ideal.
Previous Comments:
------------------------------------------------------------------------
[2010-07-09 15:08:37] cweiske
While the filter_var rule is a good idea itself, is it not something I
would advise people to use for validating email addresses with QF2 -
it's a common task that requires an own rule IMO.
------------------------------------------------------------------------
[2010-07-09 11:02:27] hm2k
I wrote a whole essay on this matter:
http://www.hm2k.com/posts/what-is-a-valid-email-addressIt pretty much addresses my concerns here.
------------------------------------------------------------------------
[2010-07-09 10:30:17] mansion
We could also add a new rule simply called 'filter_var' or 'filter' that
would in turn
call the function filter_var() with given parameters ? It would make
things easier
than using the callback rule. The filter extension is apparently enabled
by default
since PHP 5.2, which is our minimum version for using QF2 so it should
be ok.
The filter_var email regex is a bit difficult to read and will validate
addresses with
IPv4 or IPv6 in place of domain names which might not always be what you
expect.
At the moment, I use this regex instead :
"/^[_+a-z0-9-]+(\.[_+a-z0-9-']+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-
z]{2,}){1}$/"
It's not perfect but it fits my needs.
------------------------------------------------------------------------
[2010-07-09 10:10:45] hm2k
It would make sense, especially as previously PHP used to base it's
FILTER_VALIDATE_EMAIL on HTML_QuickForm's regex.
Where once HTML_QuickForm was leading the way, HTML_QuickForm2 has not
filled that gap.
Let's see it return.
------------------------------------------------------------------------
[2010-07-09 09:50:24] cweiske
One could easily use PHP's filter method to check if a string is a valid
email:
function isValidEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}
That would need to be combined with a callback.
But yes, it'd be cool if that rule would exist in HTML_QuickForm2 by
default since it's a common usecase.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=16906