# validation.uk-company-number
Checks that a Companies House company registration number (CRN) has the shape
Companies House issues, with a prefix it uses, and returns it as the eight
characters the register and its API expect, with what the prefix means.
A PASS IS NOT A COMPANY. Company numbers carry no check digit. A pass means
the number is well formed; whether it is on the register, and whether it is
still active, is a lookup on the Companies House register or API.
## The format
Eight characters: eight digits for a company registered in England and Wales,
or a two-character prefix and six digits for everything else (SC Scotland, NI
Northern Ireland, OC/SO/NC limited liability partnerships, LP/SL/NL limited
partnerships, FC overseas companies, and so on). R0, for pre-partition
Northern Ireland companies, is the one prefix with a digit in it.
Leading zeros are part of the number, and dropping them names a different
company or none. Because people drop them when typing, a number short of its
zeros is padded back: "2050399" becomes "02050399" and "sc 2180" becomes
"SC002180". A number of nothing but zeros is refused.
## The prefix table (data)
`data/company-prefixes.json` holds every prefix in Companies House's list of
company numbers and prefixes, including the ones for which Companies House
holds only the name and number (industrial and provident societies, ICVCs,
royal charter companies, credit unions). A prefix not in the table is
`unknown-prefix`. Companies House does add prefixes from time to time, so an
unknown prefix can be a new one. A prefix added in future is a data release
of this capability.
## Input and result
Case is ignored and ASCII spaces are ignored anywhere. Anything else that is
not an ASCII letter or digit, hyphens included, is `bad-character`.
Validators answer rather than throw.
| reason | meaning (checked in this order) |
|---|---|
| `empty` | nothing but spaces, or not a string |
| `bad-character` | a character other than an ASCII letter, digit or space |
| `bad-format` | a single leading letter, letters after the prefix, or all zeros |
| `bad-length` | no digits, or more than eight characters in all |
| `unknown-prefix` | a prefix not in the table |
## Source
Companies House, "Uniform Resource Identifiers (URI) Customer Guide", version
1.1, section "List of Company Numbers and Prefixes":
https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/426891/uniformResourceIdentifiersCustomerGuide.pdf
2.0.0 renames the function from `ukCompanyNumber` to `validateUkCompanyNumber` (`validate_uk_company_number` in Python and
Rust), so every validator that returns a result record is `validateX` and
every one that returns a bool is `isX`. Nothing else changed; 1.0.0 stays
published under the old name.
## Notices
Contains public sector information licensed under the Open Government
Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).
2.0.1 adds its attribution notices (NOTICE). The code and the tests are unchanged.