<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_path(xj_path):
 """Validates XJ path. :param str xj_path: XJ Path :raise: XJPathError if validation fails. """


    if not isinstance(xj_path, str):
        raise XJPathError('XJPath must be a string')

    for path in split(xj_path, '.'):
        if path == '*':
            continue
        if path.startswith('@'):
            if path == '@first' or path == '@last':
                continue
            try:
                int(path[1:])
            except ValueError:
                raise XJPathError('Array index must be either integer or '
                                  '@first or @last')