<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_pattern(fn):
 """On success return an absolute path and a pattern. Otherwise print a message and return None, None """

    directory, pattern = parse_pattern(fn)
    if directory is None:
        print_err("Invalid pattern {}.".format(fn))
        return None, None
    target = resolve_path(directory)
    mode = auto(get_mode, target)
    if not mode_exists(mode):
        print_err("cannot access '{}': No such file or directory".format(fn))
        return None, None
    if not mode_isdir(mode):
        print_err("cannot access '{}': Not a directory".format(fn))
        return None, None
    return target, pattern