Bagaimana cara memeriksa apakah kupon valid atau tidak magento 2

//normaly there should be only one rule that gets here since you can apply only one coupon code
$quote->setCouponCode('YOUR_COUPON')->collectTotals()->save(); 
$quoteCouponCode = $quote->getCouponCode();//get the applied coupon code from the quote
if ($quoteCouponCode){
  //$rule is valid and $rule->getCode() is a valid coupon code
}
//remove the coupon code from the quote if you want
$quote->setCouponCode('')->collectTotals()->save(); 
Colorful Corncrake