Prevent #_id generation for invalid documents