def validate_arg_regex()

in scripts/validation_utils.py [0:0]


def validate_arg_regex(flag_value, flag_regex):
    """Check a named command line flag against a regular expression"""
    if not re.match(flag_regex, flag_value):
        raise argparse.ArgumentTypeError(
            'Value "{}" does not match pattern "{}"'.format(
                flag_value, flag_regex.pattern))
    return flag_value