Everything is possible.
You can override CartRule.php and change the checkValidity function.
Here you can check the quantity in stock and if one item does not have enough, for example, display an error and do not apply the code.
Another option is a custom module and a hook that would check the quantity and display the text below the voucher insertion.
Edit History
Everything is possible.
You can override CartRule.php and change the checkValidity function.
Here you can check the number of pieces in stock and if one item does not have enough, for example, display an error and do not apply the code.
Another option is a custom module and a hook that would check the numbers and display the text below the voucher insertion.