Laravel 5.4 form validation, the attribute name in the error prompt is adjusted to Chinese implementation
1. Laravel’s form validation, there is English in the error prompt, mainly the attribute name of the verification: Winning Limit. as shown in Figure 1
{
"code": 10000,
"message": "winning limit 必须是整数。",
"data": []
}
2. Check the verification code as follows
$input = $request->json()->all();
Arr::set($input, 'activity_id', $activityId);
$factory = Container::getInstance()->make('validator');
$validator = $factory->make($input, [
'activity_id' => 'required|uuid|exists:activities,id',
'prize_id' => 'required|uuid|exists:prizes,id',
'winning_limit' => 'integer',
'stock_limit' => 'numeric',
'winning_probability' => 'numeric|between:0,1',
]);
3. Reference URL:https://learnku.com/docs/laravel/5.4/validation/1234#42c1ed. Customize properties in language files. If you want to replace the :attribute part of the validation message with a custom attribute name, you can specify a custom name in the attributes array of the resources/lang/xx/validation.php language file. Edit: resources/lang/en-cn/validation.php
'attributes' => [
'winning_limit' => '中奖限制',
],
4. Laravel’s form validation, the attribute name in the error message: Winning Limit has been replaced with: winning limit. in line with expectations. as shown in Figure 2
{
"code": 10000,
"message": "中奖限制 必须是整数。",
"data": []
}

