def is_valid_object_id(value):
try:<EOL><INDENT>OBJECT_ID.validate(value)<EOL>return True<EOL><DEDENT>except ValidationError:<EOL><INDENT>return False<EOL><DEDENT>
Validates BSON IDs using mongoengine's ObjectIdField field.