bval-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: Why does EmailValidator match null & ""?
Date Thu, 28 Feb 2013 22:18:02 GMT
hi matthew,

that's perfectly fine according to the specification.
handling null and empty values should be done by the constraint-validator/s
which are responsible for those values.

regards,
gerhard



2013/2/28 Matthew Adams <matthew@matthewadams.me>

> Email validator seems to consider null and empty string ("") valid email.
>  See
> https://svn.apache.org/repos/asf/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java:
>
>     public static boolean isValid(Object value, Pattern aPattern) {*        if (value
== null)
>             return true;
>         if (!(value instanceof CharSequence))
>             return false;
>         CharSequence seq = (CharSequence) value;
>         if (seq.length() == 0)
>             return true;*
>         Matcher m = aPattern.matcher(seq);
>         return m.matches();
>     }
>
> That surprises me.  Does it surprise anyone else?  Can we get that
> changed?  I'd be happy to file an issue (and patch).
>
> -matthew
>
> --
> mailto:matthew@matthewadams.me <matthew@matthewadams.me>
> skype:matthewadams12
> googletalk:matthew@matthewadams.me
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
>

Mime
View raw message