CCC (Código Cuenta Corriente, Spanish Bank Account Code)

CCC code is the country-specific part in Spanish IBAN codes. In order to fully validate an Spanish IBAN you have to validate as well the country specific part as a valid CCC. It was used for home banking transactions until February 1st 2014 when IBAN codes started to be used as an account ID.

The CCC has 20 digits, all being numbers: EEEE OOOO DD NNNNNNNNNN

  • EEEE: banking entity
  • OOOO: office
  • DD: check digits
  • NNNNN NNNNN: account identifier

This module does not check if the bank code to exist. Existing bank codes are published on the ‘Registro de Entidades’ by ‘Banco de España’ (Spanish Central Bank).

More information:

>>> validate('1234-1234-16 1234567890')
>>> validate('134-1234-16 1234567890')  # wrong length
Traceback (most recent call last):
InvalidLength: ...
>>> validate('12X4-1234-16 1234567890')  # non numbers
Traceback (most recent call last):
InvalidFormat: ...
>>> validate('1234-1234-00 1234567890')  # invalid check digits
Traceback (most recent call last):
InvalidChecksum: ...
>>> format('12341234161234567890')
'1234 1234 16 12345 67890'
>>> to_iban('21000418450200051331')

Calculate the check digits for the number. The supplied number should have check digits included but are ignored.

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

Reformat the number to the standard presentation format.

Check if the number provided is a valid CCC.

Convert the number to an IBAN.

Check if the number provided is a valid CCC.