Form validation not triggered at first submit, but on second submit I'm in the need for a extra validation on an existing drupal commerce form (commerce_cart_add_to_cart_form_##), strangely the validation function is not called on the first form submit, but on the 2nd submit and all the submits after the 2nd. There are multiple commerce_cart_add_to_cart_forms on a single page.

Here's my module code:

function val_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if (strpos($form_id, 'commerce_cart_add_to_cart_form_') !== false) {
        $form['#validate'][] = 'val_commerce_cart_add_to_cart_form_validate';
    }
}

function val_commerce_cart_add_to_cart_form_validate($form, &amp;$form_state) {
    dpm('validating function called');
    form_set_error('quantity', t("ERROR"));
}


Any Ideas? 
And, as a second question: there are different $from_ids (commerce_cart_add_to_cart_form_##) that will all need the same validation. Is there a way to call them all other than I did?

Thanks!
I added your code to a quick dummy function, tested it, and the it seems to be working fine. I created a dummy item, added it to my cart, and the that produced a print out like:

 

I also added a watchdog() call to the validate function and that confirmed the validation was being called when it should be. I'm not sure if maybe you have something else interfering with your form alter or possibly your dpm is printing out late (I know it can happen with themes, not sure with modules), but you might want to try using watch dog to see if the validation form isn't being called when it should.