|string> */ public function rules(): array { return [ 'authorizationCode' => [ 'nullable', Rule::requiredIf($this->input('provider') === SocialProvider::Apple->value), 'string', 'max:4096', ], 'deviceName' => ['sometimes', 'string', 'max:255'], 'device_name' => ['sometimes', 'string', 'max:255'], 'idToken' => ['required', 'string', 'max:10000'], 'intent' => ['required', Rule::in(['login', 'register'])], 'locale' => ['sometimes', 'string', Rule::in(config('app.supported_locales', ['fr', 'en']))], 'name' => ['sometimes', 'nullable', 'string', 'max:255'], 'nonce' => ['required', 'string', 'size:64', 'regex:/\A[a-f0-9]{64}\z/'], 'provider' => ['required', Rule::enum(SocialProvider::class)], 'termsAccepted' => ['required', 'boolean'], ]; } protected function prepareForValidation(): void { if ($this->has('locale')) { $locale = strtolower(str_replace('_', '-', (string) $this->input('locale'))); $this->merge([ 'locale' => explode('-', $locale)[0], ]); } if ($this->has('deviceName') && ! $this->has('device_name')) { $this->merge([ 'device_name' => $this->input('deviceName'), ]); } } }