Did I find the right examples for you? yes no

All Samples(14)  |  Call(12)  |  Derive(0)  |  Import(2)
Goes through all known type validators 

:param val: The value to validate
:return: True is value is valid otherwise an exception is raised

        def valid_anytype(val):
    """ Goes through all known type validators 
    
    :param val: The value to validate
    :return: True is value is valid otherwise an exception is raised
    """
    for validator in VALIDATOR.values():
        if validator == valid_anytype:  # To hinder recursion
            continue
        try:
            if validator(val):
                return True
        except NotValid:
            pass
    
    if isinstance(val, type):
        return True
        
    raise NotValid("AnyType")
        


src/p/y/pysaml2-2.0.0/tests/test_13_validate.py   pysaml2(Download)
from saml2.validate import valid_any_uri
from saml2.validate import NotValid
from saml2.validate import valid_anytype
 
from py.test import raises
def test_valid_anytype():
    assert valid_anytype("130.239.16.3")
    assert valid_anytype("textstring")
    assert valid_anytype("12345678")
    assert valid_anytype("-1234")

src/p/y/pysaml2-HEAD/tests/test_13_validate.py   pysaml2(Download)
from saml2.validate import valid_any_uri
from saml2.validate import NotValid
from saml2.validate import valid_anytype
 
from py.test import raises
def test_valid_anytype():
    assert valid_anytype("130.239.16.3")
    assert valid_anytype("textstring")
    assert valid_anytype("12345678")
    assert valid_anytype("-1234")