Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

Remove attributes from the language file #37

@lhsazevedo

Description

@lhsazevedo

By default, Laravel's validation messages include the attribute name, contrary to the backend specification.

This was achieved by removing the first two words of each error message during runtime, instead of editing the language file directly.

$validationErrors = array_map(function($error) {
return array_map(function($message) {
return remove_words($message, 2);
}, $error);
}, $validationErrors);
return response()->json(['errors' => $validationErrors], 422);

Besides being unnecessary, this is a bad practice because, depending on the language, the name of the attribute will not necessarily be in the first two words.

The removal of attributes was even proposed by Laravel-Lang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions