Closed Thiagocfn closed 7 years ago
The signature of the Validator::email
methods looks like that:
public function email($field, $checkMX = false, $message = null, $when = null)
So you have to add your message as the third parameter.
Also, this is the wrong repo for this kind of issues. Please head over to https://github.com/cakephp/cakephp the next time 😄
Not a bug, just a misunderstanding. Note: all simple validation have a pattern: $validator ->{{validation}}('field', 'create|update\callback', 'message') or $validator ->{{validation}}('field', 'message')
but the validation e-mail structure is: $validator ->email('field', 'checkMX: bool','message or null', 'when or null')
how we can se on API https://api.cakephp.org/3.0/class-Cake.Validation.Validation.html#_email
But there is no information about on cookbook in any mention about e-mail validation https://book.cakephp.org/3.0/en/core-libraries/validation.html
I recommend add that mention and/or adjust the structure of e-mail validation to be intuitive and be similar than other ones.
@cleptric thanx. i'm was writting just when you wrote that message.
I appreciate your answer and ask you to take some note to my previous considerations and why i made that mistake. I'll write in the right section at next time if i find other problem.
Thank you
https://api.cakephp.org/3.0/class-Cake.Validation.Validation.html#_email is the wrong class. This is the generic validation class. You're looking for https://api.cakephp.org/3.4/class-Cake.Validation.Validator.html#_email
@cleptric Thank you, and I apologize for misunderstood that. But take a note to that different structure and no mention about that on "cookbook" email validation usage,
Regards.
No problem at all 🙂 I'll take a look at the docs and see how we can improve this.
This is a (multiple allowed):
[x] bug
[ ] enhancement
[ ] feature-discussion (RFC)
CakePHP Application Skeleton Version: 3.3.16
Platform and Target: Controller integration test. E-mail validation.
What you did
Tryed to test a e-mail validation.
on entity table class added following `validations:
there's no other validation rules to this field.
on test there is:
On register action:
response body:
What happened
On run that test, we receive an generic error about validation e-mail: "The provided value is invalid". But there'is no other validation rules. No field manipulation.
e-mails that i received success: thiago@silva.com.br //fake, but well formed thiago@aaa.com.br //fake, but well formed e-mails failed and received generic message error: alexander.oliveira@microsffer.com //real e-mail thiago@sss.com.br //fake, but well formed
What you expected to happen
I expect to validade any well formed e-mails, as well receive one of my custom messages that i had specified on validation rules, in case of failure.
I guess there is a bug or technical uncompliance with e-mail validation rules.