happypixels / laravel-shopr

A developer-friendly e-commerce foundation for your Laravel app
https://laravel-shopr.happypixels.se
MIT License
208 stars 19 forks source link

Validation error when applying a coupon #13

Closed Reached closed 5 years ago

Reached commented 5 years ago

Describe the bug A clear and concise description of what the bug is.

When trying to add a coupon code a 422 validation error is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Make sure your database contains a valid coupon
  2. Make an ajax post request to the "/api/shopr/cart/discounts" endpoint with a body of a code {code: 'somecode'}
  3. See 422 validation error in the console

Might help My assumption is that the rules array is colliding with the custom rules array set in the configuration file, because I tried to override the original rules array in CartDiscountController.php $rules = ['required', 'string']; with my own implementation it worked:

$request->validate([
            'code' => 'required|string'
        ]);

instead of

$rules = ['required', 'string'];

But obviously this is not compatible with the custom rules 🤔

mattias-persson commented 5 years ago

@Reached Interesting! What was the exact validation error you received? I'll look into it!

Reached commented 5 years ago

My bad, I simply think that I made a mistake somewhere! It appears to be working correctly now 🤔 Sorry if I wasted your time!