import http


def _is_value_defined(entity, field_name, defined_values):
    """Checks if a value of a field of an entity is defined.

    Args:
        entity: Entity as a dict.
        field_name: Name of the field as a string. If this field does not exist
            in the entity, the function does not perform the check.
        defined_values: Collection of defined values. Each of the elements
            should be of the same type as the value of the field.

    Returns:
        See module docstring.
    """
    status = entity.get(field_name)
    if status and status not in defined_values:
        return (False, f'{field_name} {status} is not allowed',
                http.HTTPStatus.FORBIDDEN)
    return True, None, None