I have translated the Larvel validation into Japanese, and it says, "Please enter half-width alphanumeric characters for name" as shown in the image.
"I would like to make this ""Please enter your account name in half-width alphanumeric characters."""
The original validation message is ":attribute should be half-width alphanumeric characters", so if you write "Please enter half-width alphanumeric characters for your account name" in solid form, the message will certainly be correct, but I cannot use other half-width alphanumeric characters.
Can I change the :attribute
part in Japanese every time I use validation?
If there is a way, please let me know.
php laravel
According to the documentation,
https://laravel.com/docs/6.x/validation#customizing-the-validation-attributes
If you would like the: attribute port of your validation message to be replaced with a custom attribute name, you may specify the custom names by overriding the attributes method. This method should return an array of attribute/name pairs:
So, why don't we override the following attributes
method to the Requests class that we created?
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes()
{
return [
'name' = > 'Account Name',
];
}
© 2024 OneMinuteCode. All rights reserved.