Editor 1.9 - email validation not working
Editor 1.9 - email validation not working

This built in Editor validator checks the validity of an email address but it does not check if the email field is filled at all. Looks like a bug. It should produce an error message for empty email fields:
Field::inst( 'user.email' )
->validator( 'Validate::email', array( 'required' => true,
'message' => $msg[1]) ),
I replaced it with a custom PHP validator and now it works
Field::inst( 'user.email' )
->validator( function ( $val, $data, $opts ) use ( $msg ) {
if ( ! filter_var(trim($val), FILTER_VALIDATE_EMAIL) ) {
return $msg[1];
}
return true;
} ),
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @rf1234 ,
Yep, agreed. I've raised it internally (DD-1021 for my reference) and we'll report back here when there's an update.
Cheers,
Colin
Thanks Colin!
I see I used an older version of the built in validator anyway. The current version will probably work?!
Quick question:
I built this to validate a string of comma or semi-colon separated email addresses and save it as a comma separated string of email addresses in a text field. Is there a built-in Editor validator for this as well?
Yes, I believe it should work with the latest libraries. I've just tried it and it appears to work as expected. I can't find the commit that fixed it is the only thing, but then the PHP libraries were split into a public Github repo with the 1.8 release. What version were you using?
No. A custom validator would be the way to do that.
Allan
I use Editor 1.9 Javascript and PHP libraries downloaded from your site.