# stdnum.es.postal_code

Postcode (the Spanish postal code).

The Spanish postal code consists of five digits where the first two digits, ranging 01 to 52, correspond either to one of the 50 provinces of Spain or to one of the two autonomous cities on the African coast.

More information:

- https://en.wikipedia.org/wiki/Postal_codes_in_Spain

    >>> validate('01000')
    '01000'
    >>> validate('52000')
    '52000'
    >>> validate('00000')
    Traceback (most recent call last):
        ...
    InvalidComponent: ...
    >>> validate('53000')
    Traceback (most recent call last):
        ...
    InvalidComponent: ...
    >>> validate('99999')
    Traceback (most recent call last):
        ...
    InvalidComponent: ...
    >>> validate('5200')
    Traceback (most recent call last):
        ...
    InvalidLength: ...
    >>> validate('520000')
    Traceback (most recent call last):
        ...
    InvalidLength: ...

stdnum.es.postal_code.compact(number: str) → str

  Convert the number to the minimal representation.

stdnum.es.postal_code.is_valid(number: str) → bool

  Check if the number provided is a valid postal code.

stdnum.es.postal_code.validate(number: str) → str

  Check if the number provided is a valid postal code.