(value, matcher, require)
return value is None or matcher.match(value)
Determine if a value is valid based on the provided matcher.

    :param str value:
        Value to validate.
    :param matcher:
        Compiled regular expression to use to validate the value.
    :param require:
        Whether or not the value is required.
Determine if a value is valid based on the provided matcher.
Determine if a value is valid based on the provided matcher .
def is_valid(value, matcher, require):
    """Determine if a value is valid based on the provided matcher.

    :param str value:
        Value to validate.
    :param matcher:
        Compiled regular expression to use to validate the value.
    :param require:
        Whether or not the value is required.
    """
    if require:
        return (value is not None
                and matcher.match(value))

    # require is False and value is not None
    return value is None or matcher.match(value)
def is_valid ( value , matcher , require ) : if require : return ( value is not None and matcher . match ( value ) ) # require is False and value is not None return value is None or matcher . match ( value )