Move validate_file() check into validate_element().