def matches(property_name, regex, *, present_optional=False, message=None):
    """Returns a Validation that checks a property against a regex."""
    def check(val):
      """Checks that a value matches a scope-enclosed regex."""
      if not val:
        return present_optional
      else:
        return True if regex.search(val) else False

    return Validation(check, property_name, message)
Returns a Validation that checks a property against a regex.