Back-end validation of product variant
Well, if you submit to your add to cart form via ajax, you will already get a json response - with an error - you can simply grab that error, test for Not a purchasable ID and then change the text to whatever you want.

If you're submitting in a non ajax fashion, you won't get a JSON response no matter what clearly.

I agree with the comment above - I'd generally handle this in front end JS, by disabling the add to cart until a size is selected.  And I guess if you're allowing your site to use no-js, then in that case I would probably just pre-select the most popular option (Medium, presumably).

You can also write a plugin that listens to https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart and does whatever validation you need, and returns a response any way you want, including via JSON (i.e. $this-&gt;returnJson(["success"=&gt;true]); or e.g. $this-&gt;returnErrorJson($errors); where $errors holds your validation errors...)