Sylius / ShopApiPlugin

Shop API for Sylius.
https://sylius.com
129 stars 89 forks source link

Update AddProductReviewByCodeRequest.php #635

Closed aike-ps closed 4 years ago

aike-ps commented 4 years ago

Fix bug. Rating must be only Int.

mamazu commented 4 years ago

Could you please merge this together with the other merge request you did. (#634)

mamazu commented 4 years ago

One thing I am thinking about is that you cahnged the default value. With get the default value if the property does not exist is null and the default value of getInt is 0 so there is no way of differenticating between not rated and rated very badly.

aike-ps commented 4 years ago

Yes, now not working at all, good luck )))

aike-ps commented 4 years ago
AddProductReviewByCode
 public function __construct(
        string $productCode,
        string $channelCode,
        string $title,
        **int $rating,**
        string $comment,
        string $email
    )
mamazu commented 4 years ago

Thanks for pointing that out. Yes the store rating hast to be an integer but the fact that field is filled with something other than null should be validated at the request level. So if you create a review without giving it a rating then the validator should return a 400 and never trigger the command.