Matthijn
Matthijn

Reputation: 3234

Laravel validation non localized error messages

When using the Validator the error messages contain the localized version of the errors which is nice for displaying on a website. But in my API I want the non localized error messages to be displayed. E.g instead of The :attribute field is required. I would like required as the error.

How can I get the non-localized error messages from the validator?

Upvotes: 0

Views: 1214

Answers (1)

Philipe
Philipe

Reputation: 572

In the Laravel Validation documentation there is a example of this. Take a look at Validating Multiple Fields topic.

See:

if ($validator->fails())
{
    $messages = $validator->messages(); // get the messages
    $failed = $validator->failed(); // get the failed rules
}

I hope this helps.

Upvotes: 1

Related Questions