Skip to content
organisationsnummerPublic

About

Validate Swedish organization numbers

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

35 Commits

Folders and files

Repository files navigation

organisationsnummer Build Status

Validate Swedish organization numbers. Follows version 1.1 of the specification.

Installation

pip install organisationsnummer

or

pip3 install organisationsnummer

Examples

  • All examples that uses organisationsnummer.Organisationsnummer([params]), can be replaced with organisationsnummer.parse([params]).
  • The number must be passed as a string.

Validation

from organisationsnummer import organisationsnummer

organisationsnummer.valid("202100-5489")
# => True

organisationsnummer.valid("2021005489")
# => True

organisationsnummer.valid("202100-5480")
# => False

Format

from organisationsnummer import organisationsnummer

# Short format
on = organisationsnummer.Organisationsnummer("202100-5489")
on.format()
# => '2021005489'

# Long format
on = organisationsnummer.Organisationsnummer("2021005489")
on.format(True)
# => '202100-5489'

Type and VAT number

from organisationsnummer import organisationsnummer

on = organisationsnummer.parse("202100-5489")
on.type()
# => 'Stat, landsting, kommun eller församling'

on.vat_number()
# => 'SE202100548901'

Invalid numbers

from organisationsnummer import organisationsnummer

organisationsnummer.parse("202100-5480")
# => raises OrganisationsnummerInvalidException

See organisationsnummer/tests/test_organisationsnummer.py for more examples.

In memoriam

Fredrik "Frozzare" Forsmo (1991-2026) was the initiator, co-founder and a core contributor of the organisationsnummer project. This library carries his work. He is missed.

License

MIT

About

Validate Swedish organization numbers

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages