Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I give user error message I want to give #705

Closed
Justin0983 opened this issue Jul 21, 2016 · 2 comments
Closed

How can I give user error message I want to give #705

Justin0983 opened this issue Jul 21, 2016 · 2 comments

Comments

@Justin0983
Copy link

Hi,there.I need a favor.
I don't use default error message when I validate some data.Just give user error message I specified.

$userValidator = v::attribute('name', v::stringType()->length(1,32))
->attribute('birthdate', v::date()->age(18));

$userValidator->validate($user);

like code above,how to make it happen?Such as validate 'name',give user a kind of message that 'name you input is invalid' I specified.

Thank you for your help!

@seitbekir
Copy link

seitbekir commented Jul 30, 2016

It is really good question.

Hey, guys. What about make something like in popular NodeJS validators.

like

$field = v::numberic("the value must be null");

Or

$field = v::numberic(new ValidationError("the value must be null"));

Last is not looks pretty, but it more useful;

@henriquemoody
Copy link
Member

You can specify your own messages with findMessages(), see http://respect.github.io/Validation/docs/#getting-messages-as-an-array-by-name

If my answer is not enough, feel free to reopen this issue or create a new one any time.

🐼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants