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

Error message not changing #105

Open
gmarkmananquil opened this issue Oct 10, 2019 · 1 comment
Open

Error message not changing #105

gmarkmananquil opened this issue Oct 10, 2019 · 1 comment

Comments

@gmarkmananquil
Copy link

I tried to change the error message.

$validator->setMessages([
"required", ":attribute is empty",
"password:min", ":attribute characters should not less than 6"
]);
$validation = $validator->validate($request->post("all"), [
"username" => "required",
"password" => "required|min:6"
]
);

but the output is like this.

object(Rakit\Validation\ErrorBag)#678 (1) { ["messages":protected]=> array(2) {
["username"]=> array(1) { ["required"]=> string(24) "The Username is required" }
["password"]=> array(1) { ["min"]=> string(25) "The Password minimum is 6" } }
}

@thiagomeireless
Copy link

thiagomeireless commented Oct 11, 2019

Your setMessages() call is wrong, you need to pass data in array format, like:

$validator->setMessages([
  "required"     => ":attribute is empty",
  "password:min" => ":attribute characters should not less than 6"
]);


$validation = $validator->validate($request->post("all"), [
  "username" => "required",
  "password" => "required|min:6"
]);

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

2 participants