コード例 #1
0
def validate(number):
    """Check if the number provided is a valid ISO 11649 structured creditor
    reference number."""
    number = compact(number)
    if len(number) < 5 or len(number) > 25:
        raise InvalidLength()
    if not number.startswith('RF'):
        raise InvalidFormat()
    mod_97_10.validate(number[4:] + number[:4])
    return number
コード例 #2
0
def validate(number):
    """Check if the number provided is a valid AT-02."""
    number = compact(number)
    try:
        test_number = _to_base10(number)
    except Exception:
        raise InvalidFormat()
    # ensure that checksum is valid
    mod_97_10.validate(test_number)
    return number
コード例 #3
0
def validate(number):
    """Checks to see if the number provided is a valid AT-02."""
    number = compact(number)
    try:
        test_number = _to_base10(number)
    except:
        raise InvalidFormat()
    # ensure that checksum is valid
    mod_97_10.validate(test_number)
    return number
コード例 #4
0
ファイル: iban.py プロジェクト: Manexware/python-stdnum
def validate(number):
    """Checks to see if the number provided is a valid IBAN."""
    number = compact(number)
    try:
        test_number = _to_base10(number)
    except Exception:
        raise InvalidFormat()
    # ensure that checksum is valid
    mod_97_10.validate(test_number)
    # look up the number
    info = _ibandb.info(number)
    # check if the bban part of number has the correct structure
    bban = number[4:]
    if not _struct_to_re(info[0][1].get('bban', '')).match(bban):
        raise InvalidFormat()
    # return the compact representation
    return number
コード例 #5
0
def validate(number):
    """Checks to see if the number provided is a valid IBAN."""
    number = compact(number)
    try:
        test_number = _to_base10(number)
    except Exception:
        raise InvalidFormat()
    # ensure that checksum is valid
    mod_97_10.validate(test_number)
    # look up the number
    info = _ibandb.info(number)
    # check if the bban part of number has the correct structure
    bban = number[4:]
    if not _struct_to_re(info[0][1].get('bban', '')).match(bban):
        raise InvalidFormat()
    # return the compact representation
    return number
コード例 #6
0
ファイル: iban.py プロジェクト: lidingnet/odoo11
def validate(number, check_country=True):
    """Check if the number provided is a valid IBAN. The country-specific
    check can be disabled with the check_country argument."""
    number = compact(number)
    # ensure that checksum is valid
    mod_97_10.validate(number[4:] + number[:4])
    # look up the number
    info = _ibandb.info(number)
    # check if the bban part of number has the correct structure
    bban = number[4:]
    if not _struct_to_re(info[0][1].get('bban', '')).match(bban):
        raise InvalidFormat()
    # check the country-specific module if it exists
    if check_country:
        module = _get_cc_module(number[:2])
        if module:
            module.validate(number)
    # return the compact representation
    return number
コード例 #7
0
ファイル: iban.py プロジェクト: vbastos/python-stdnum
def validate(number, check_country=True):
    """Checks to see if the number provided is a valid IBAN. The country-
    specific check can be disabled with the check_country argument."""
    number = compact(number)
    # ensure that checksum is valid
    mod_97_10.validate(_to_base10(number))
    # look up the number
    info = _ibandb.info(number)
    # check if the bban part of number has the correct structure
    bban = number[4:]
    if not _struct_to_re(info[0][1].get('bban', '')).match(bban):
        raise InvalidFormat()
    # check the country-specific module if it exists
    if check_country:
        module = _get_cc_module(number[:2])
        if module:
            module.validate(number)
    # return the compact representation
    return number
コード例 #8
0
 def test_mod97_10(self):
     sequence = self.get_sequence("ISO7064_97_10")
     self.assertTrue(mod_97_10.validate(sequence.next_by_id()))
コード例 #9
0
def validate(number):
    """Check if the number is valid. This checks the length, format and check
    digits."""
    number = compact(number)
    mod_97_10.validate(number)
    return number