def METHOD_NAME(obj, name, expected='any'):
    """
    Validate that a given object is a valid `PixCoord`.
    Parameters
    ----------
    obj : `PixCoord`
        The object to check.
    name : str
        The parameter name used for error messages.
    expected : {'any', 'scalar', 'array'}
        What kind of PixCoord to check for.
    Returns
    -------
    obj : `PixCoord`
        The input object, if valid.
    """
    if not isinstance(obj, PixCoord):
        raise TypeError(f'{name!r} must be a PixCoord')
    if expected == 'any':
        pass
    elif expected == 'scalar':
        if not obj.isscalar:
            raise ValueError(f'{name!r} must be a scalar PixCoord')
    elif expected == 'array':
        if obj.isscalar:
            raise ValueError(f'{name!r} must be a PixCoord array')
    else:
        raise ValueError(f'Invalid value for "expected": {expected!r}')
    return obj