Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perarnborg/se-org-no
https://github.com/perarnborg/se-org-no
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/perarnborg/se-org-no
- Owner: perarnborg
- License: mit
- Created: 2018-04-27T21:31:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T03:57:42.000Z (almost 2 years ago)
- Last Synced: 2024-08-09T02:54:31.702Z (4 months ago)
- Language: JavaScript
- Size: 650 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sweden - JavaScript
README
# se-org-no
Validation for Swedish style organization numbers (organisationsnummer).
## Getting started
The library is available as an [npm package](https://www.npmjs.com/package/se-org-no).
To install the package including peer dependency [se-ssn](https://www.npmjs.com/package/se-ssn) run:```bash
npm install se-ssn se-org-no --save
```Use like this:
```js
import {isValidOrgNo} from 'se-org-no'isValidOrgNo('5569565368')
//=> trueisValidOrgNo('foo')
//=> false// By default personnummer (SSN) are accepted if they are for a user that is 16 years or older
// This is for organizations of type enskild firma
isValidOrgNo('8101013608')
//=> true// To only accept other organization forms:
// Optionally validate that a ssn is for a person of at least a certain age
isValidOrgNo('8101013608', {allowSsn: false})
//=> false// Optionally validate that a ssn is for a person of at least a certain age
isValidOrgNo('8101013608', {ssnMinYears: 80})
//=> false
```If you are in a multinational context you can use the alias isValidSwedishOrgNo for clarity:
```js
import {isValidSwedishOrgNo} from 'se-org-no'isValidSwedishOrgNo('8101013608')
//=> true
```Alternatively with CommonJS:
```js
var seOrgNo = require("se-org-no")seOrgNo.isValidOrgNo('8101013608')
//=> true
```## Legacy support
IE8 is not supported.
## License
[MIT](LICENSE).