- Does **aaronadal/validator** work with Laravel 10 or 11?
- The package was last updated in 2020 and hasn’t been tested with Laravel 10/11. You’ll need to manually verify compatibility, especially with newer features like Enums or Attributes. Start with a Laravel 10.x test environment before full integration.
- How do I install and set up **aaronadal/validator** in a Laravel project?
- Run `composer require aaronadal/validator`, then define rule sets in a dedicated class (e.g., `app/Validators/UserValidator`). Use the validator’s `validate()` method in controllers or services, passing your data and rule set. Follow the README’s basic example for syntax.
- Can I reuse validation logic across controllers, jobs, and services?
- Yes, the package’s core design focuses on reusable rule sets. Define validation logic once in a class, then call it from anywhere—controllers, jobs, or even API resources—without duplicating code. This aligns with Laravel’s DRY principles.
- How does error handling compare to Laravel’s built-in Validator?
- The package provides customizable error formatting but may not match Laravel’s native JSON/API responses exactly. You can extend its error collector to align with your project’s needs. For APIs, test responses against Laravel’s default format to identify gaps.
- Is **aaronadal/validator** compatible with Laravel Form Requests?
- While it doesn’t integrate directly with Form Requests, you can use it alongside them. For example, call the validator inside a Form Request’s `rules()` method or use it in custom validation logic. It’s best suited for internal reuse, not replacing Form Requests entirely.
- What’s the performance overhead of using this package vs. Laravel’s native Validator?
- The package is lightweight, but since it’s unmaintained, there are no official benchmarks. For most use cases, the overhead should be minimal. Test with your typical payload sizes in a staging environment to compare execution time with Laravel’s built-in Validator.
- Does it support nested arrays or conditional validation like Laravel’s native Validator?
- The package likely supports basic nested arrays, but conditional validation (e.g., `required_if`) may not be as robust as Laravel’s native solution. Check the README or source code for specific rule examples. For complex logic, you might need to extend the package.
- What’s the migration path if this package stops working with newer Laravel versions?
- If compatibility breaks, refactor reusable validation logic into Laravel’s native Validator or Form Requests. The package’s design encourages centralization, so migrating should be straightforward—just replace the validator calls with Laravel’s built-in methods or Spatie’s alternatives.
- Are there any known issues with testing or mocking this validator?
- There’s no built-in testing support, so you’ll need to manually mock validator instances in PHPUnit or Pest. Test validation logic by injecting the validator class and asserting results against mock data. For complex scenarios, consider wrapping the validator in a service layer.
- How does this package compare to alternatives like Spatie’s Laravel Validation?
- Spatie’s package is actively maintained and integrates deeper with Laravel’s ecosystem, including Form Requests and testing tools. **aaronadal/validator** is simpler but lacks long-term support. Use Spatie’s if you need modern features; this package is better for lightweight, internal reuse in stable environments.