validation
validation copied to clipboard
Error message not changing
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" } } }
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"
]);