Check if form already failed validation I added a validation hook to a node creation form.

For my project, i need this validation only ONE time: basically i just check if a value already exists in the DB and i notify it to the user. If the user still submits the form, i must add it anyway.

i would like to do something like that:

if (form_did_not_fail_validation_before) {
  $form['#validate'][] = 'my_module_validation_hook';
}


in my hook_form_alter, so that validation hook is only called the first time.

I can't find a way to check if the form already failed validation, any ideas?
Two possible solutions: 1) set a session var in your validation script to flag when validation fails, then you can check if that session var is set (validation failed once) then add it anyway. 2) If you can't rely on session var, you can look at adding a custom boolean field to your user to flag this this user has failed validation once, then check if that field if true(failed once)/false(hasn't failed yet) and code accordingly, and you'd want to reset this field to false again once the node has been created in case you need to use it again for another node form.