![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@digitalarkivet/nin-validator
Advanced tools
Validating and parsing norwegian national identity numbers in Typescript
This is a validator/parser for norwegian national identity numbers, written in Typescript.
Basic usage is very simple:
import validateNin from "@digitalarkivet/nin-validator"
// The default export accepts birth numbers and D-numbers
if(!validateNin(someNin)) {
throw "Invalid NIN"
}
To extract more information, use parseNin
. Then, you have the option to specify which number types to accept. The export ALL_NIN_TYPES
include rarely-used types like H-numbers and FH-numbers, while DEFAULT_NIN_TYPES
include birth number and D number. You can also mix-and-match by using NinNumberType
directly.
import {parseNin, ALL_NIN_TYPES, DEFAULT_NIN_TYPES, NinNumberType} from "@digitalarkivet/nin-validator"
const {info, error} = parseNin(someNin)
// Is the same as
const {info, error} = parseNin(someNin, ...DEFAULT_NIN_TYPES)
// Or, to can accept all types (very rarely what you want)
const {info, error} = parseNin(someNin, ...ALL_NIN_TYPES)
// Or, to accept specific types
const {info, error} = parseNin(someNin, NinNumberType.BirthNumber, NinNumberType.HNumber)
The info
key will be undefined
on error.
On success, it contains an object with gender
, dateOfBirth
, numberType
, and isTestNumber
keys.
The error
key will contain a NinValidationError
on error, and be undefined
on success.
The Gender
enum uses the ISO/IEC 5218 codes:
parseNin
will return Not known
for FH-numbers, and in the future for "new" national identification numbers that do not carry gender information.
A JS date, midnight on the date of birth, in local time.
Contains undefined
for FH numbers.
One of the NinNumberType
values. This is a Typescript enum, backed by a string.
This flag is set to true if the number originates from "Tenor", the test utility of the norwegian tax authority.
Since Arkivverket has no reason to exclude test numbers from production use (they will not occur in real archives, and if they do, we want to display them), test numbers can not be rejected when validating a nin with nin-validator.
A NinValidationError
is one of a predefined set of error codes, saying which check failed.
FORMAT
means the input string is not 11 digits.CHECKSUM
means the checksum validation failedDATE
means the date does not exist (leap year?), or the century code did not match the individual part of the nin.INVALID_TYPE
means the nin is valid, but the type is not one of the allowed types passed to parseNin()
The test data for birth numbers, D numbers and H-numbers is synthetically generated.
The test data for "tenor test numbers" is generated by Tenor.
FAQs
Validating and parsing norwegian national identity numbers in Typescript
The npm package @digitalarkivet/nin-validator receives a total of 18 weekly downloads. As such, @digitalarkivet/nin-validator popularity was classified as not popular.
We found that @digitalarkivet/nin-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.