Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

se-orgnr-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

se-orgnr-validator

Validator for Swedish company registration numbers (organisationsnummer) in Node.js

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
153
increased by1.32%
Maintainers
1
Weekly downloads
 
Created
Source

se-orgnr-validator

Build Status npm Coverage Status JavaScript Style Guide GitHub

Validator for Swedish company registration numbers (organisationsnummer) in Node.js.

Fast, small and no dependencies.

Install

$ npm install se-orgnr-validator

Usage

const orgnrValidator = require('se-orgnr-validator')

orgnrValidator('556016-0680')
//=> true

orgnrValidator(5560160680)
//=> true

orgnrValidator(55610160680)
//=> false

API

orgnrValidator(input)

input

Type: string

The number to validate. Accepts either a string or an integer, meaning that you may omit the dash between the first 6 and the last 4 digits.

Test

npm test

Benchmark

This module was partly created since I needed a quick solution for validating Swedish company registration numbers that had OK performance and quality. After looking at some other options available, I found some issues with them. For your convenience, here is my summarised benchmark test. Please note however, that this module was not purely written for speed reasons, and could probably be improved even further.

Tested with the following datasets:

  • 500 correct numbers (gathered from https://poit.bolagsverket.se)
  • 1 000 000 generated numbers that were too long (but with correct checksum)
  • 1 000 000 generated numbers that have either 0 or 1 as its third digit (but with correct lenght and checksum)
  • 1 000 000 randomly generated numbers (but with correct lenght and checksum)
  • 1 000 000 randomly generated numbers with incorrect checksum (but with correct lenght)

The beenchmark was performed towards:

Tests made on Windows 10, 2.5GHz, 9GB RAM. Average of three iterations.

https://github.com/eckberg/se-orgnr-validatorhttps://github.com/perarnborg/se-org-no
Correct numbers3ms16ms
Long numbers160ms217ms
Third digit121ms2.31s
Random191ms1.70s
Checksum190ms2.84s

Keywords

FAQs

Package last updated on 16 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc