How can I programmatically remove the file from a managed_file form element?
hook_field_widget_form_alter(&amp;$element, &amp;$form_state, $context)


this may help you to validate your file and if validation criteria fails return empty form element.