|string> */ public function rules(): array { return [ 'code' => ['required', 'string', 'size:6', 'regex:/^\d{6}$/'], ]; } protected function prepareForValidation(): void { $code = preg_replace('/\D+/', '', (string) $this->input('code')); $this->merge([ 'code' => $code, ]); } }