12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Http\Requests\API\User;
- use App\Http\Requests\RuleHelper;
- use Illuminate\Foundation\Http\FormRequest;
- class CreateOrUpdateRequest extends FormRequest
- {
- use RuleHelper;
- /**
- * Determine if the user is authorized to make this request.
- */
- public function authorize(): bool
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
- */
- public function rules(): array
- {
- return [
- 'name' => 'required|max:100',
- 'email'=> 'required|email|unique:users',
- 'username'=>'required|max:30|unique:users',
- 'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$/', // 至少6位,包含大小写字母和数字
- 'confirm_password' => 'required|same:password', // 与password字段相同
- 'phone'=>'nullable|regex:/^\d{10}$/',
- 'gender'=>'nullable|in:1,0',
- 'address'=>'nullable|max:255',
- 'company_id'=>'required|exists:company,id',
- 'department_id'=>'required|exists:department,id',
- 'role_id'=>'required|exists:roles,id',
- ];
- }
- }
|