12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Http\Requests\Coach;
- use Illuminate\Foundation\Http\FormRequest;
- class SubmitBaseInfoRequest extends FormRequest
- {
- public function authorize()
- {
- return true;
- }
- public function rules()
- {
- return [
- 'nickname' => 'required|string|min:2|max:20',
- 'avatar' => 'required|url|max:255',
- 'gender' => 'required|in:1,2',
- 'mobile' => ['required', 'string', 'regex:/^1[3-9]\d{9}$/'],
- 'birthday' => [
- 'required',
- 'date',
- 'before:'.now()->subYears(18)->format('Y-m-d'),
- ],
- 'work_years' => 'required|integer|min:0|max:99',
- 'intention_city' => 'required|string|max:50',
- 'introduction' => 'required|string|min:10|max:255',
- ];
- }
- public function messages()
- {
- return [
- 'nickname.required' => '昵称不能为空',
- 'nickname.min' => '昵称不能少于2个字符',
- 'nickname.max' => '昵称不能超过20个字符',
- 'avatar.required' => '头像不能为空',
- 'avatar.url' => '头像必须是有效的URL地址',
- 'gender.required' => '性别不能为空',
- 'gender.in' => '性别只能是1(男)或2(女)',
- 'mobile.required' => '手机号不能为空',
- 'mobile.regex' => '手机号格式不正确',
- 'birthday.required' => '出生日期不能为空',
- 'birthday.date' => '出生日期格式不正确',
- 'birthday.before' => '年龄必须满18岁',
- 'work_years.required' => '工作年限不能为空',
- 'work_years.integer' => '工作年限必须是整数',
- 'work_years.min' => '工作年限不能小于0年',
- 'work_years.max' => '工作年限不能超过99年',
- 'intention_city.required' => '意向城市不能为空',
- 'intention_city.max' => '意向城市不能超过50个字符',
- 'introduction.required' => '个人简介不能为空',
- 'introduction.min' => '个人简介不能少于10个字符',
- 'introduction.max' => '个人简介不能超过255个字符',
- ];
- }
- }
|