- How does this package handle Livewire’s camelCase property names vs. Laravel’s snake_case validation rules?
- The package includes an optional camelCase ↔ snake_case conversion feature, disabled by default to avoid unintended side effects. Enable it globally in your `AppServiceProvider` only if your project requires it. For most cases, you can manually map properties in `validateLivewire()` to align with your validation rules.
- Will this work with Laravel Sanctum or Passport for API validation?
- Yes, the package is fully compatible with Laravel Sanctum and Passport. It treats API requests the same as HTTP requests, so your existing API validation logic (including auth checks) will work seamlessly without modifications.
- Can I migrate existing FormRequests incrementally, or do I need to rewrite everything at once?
- You can migrate incrementally. Start by extending `CombinedFormRequest` for non-critical components, then gradually replace `validate()` calls in Livewire with `validateLivewire()`. The package won’t break existing FormRequests, so you can phase it in.
- Does this package support file uploads in Livewire components?
- Yes, the package fully supports Livewire file uploads, including temporary file handling. Use the same validation rules for both HTTP and Livewire contexts, and the package will manage file validation and storage consistently.
- What happens if I forget to pass a required parameter in Livewire?
- The package will throw a validation error (just like Laravel’s FormRequest), but you’ll need to handle the error in your Livewire component. For better UX, set up global authorization notifiers in your `AppServiceProvider` to display toast messages or flash notifications.
- Is there a performance impact compared to using separate FormRequests for HTTP and Livewire?
- The performance impact is negligible for most applications. The package reuses the same validation logic, so there’s no overhead from duplicate rule processing. For high-traffic APIs, benchmark your specific use case, but the unified approach typically improves maintainability more than it affects speed.
- How do I handle authorization failures in Livewire components?
- Authorization failures in Livewire will trigger validation errors by default. To customize the response (e.g., show a toast), use the `failedAuthorization()` method in your `CombinedFormRequest` or set up a global handler in your `AppServiceProvider` to redirect or notify users.
- Does this package work with Laravel 9 or Livewire 2?
- No, this package requires **PHP 8.1+**, **Laravel 10/11/12**, and **Livewire 3/4**. It leverages modern PHP features like named arguments and union types, so it won’t work with older versions. Check the [Livewire roadmap](https://github.com/livewire/livewire) for future compatibility.
- Can I use this for nested forms or multi-step Livewire workflows?
- Yes, the package supports complex workflows. For nested forms, define your validation rules as usual, and pass the nested data structure to `validateLivewire()`. Required parameters are enforced the same way in both HTTP and Livewire contexts, so your logic remains consistent.
- What’s the best way to test this package in my application?
- Test both HTTP and Livewire paths separately. Use Laravel’s `FormRequest` testing helpers for HTTP routes and manually trigger `validateLivewire()` in your Livewire component tests. Focus on edge cases like missing parameters, authorization failures, and file uploads to ensure consistency across contexts.