Returns a validator which allows the value to be missing.
    Similar to :func:`optional` but wraps a string in
    :class:`~monk.validators.Equals` instead of :class:`~monk.validators.IsA`.
    Intended for dictionary keys.

    ::

        >>> opt_key(str) == IsA(str) | ~Exists()
        True
        >>> opt_key('foo') == Equals('foo') | ~Exists()
        True

def opt_key(spec):
    """
    Returns a validator which allows the value to be missing.
    Similar to :func:`optional` but wraps a string in
    :class:`~monk.validators.Equals` instead of :class:`~monk.validators.IsA`.
    Intended for dictionary keys.

    ::

        >>> opt_key(str) == IsA(str) | ~Exists()
        True
        >>> opt_key('foo') == Equals('foo') | ~Exists()
        True

    """
    if isinstance(spec, text_types):
        spec = Equals(spec)
    return optional(spec)