diff --git a/.eslintignore b/.eslintignore index 4f8fb4f..d59fd19 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ node_modules -dist +build jest.config.js diff --git a/.gitignore b/.gitignore index e01ceaa..e9764fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ **/.DS_Store node_modules -dist +build .vscode \ No newline at end of file diff --git a/README.md b/README.md index 63a82e0..b018160 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ import {parseNin, ALL_NIN_TYPES, DEFAULT_NIN_TYPES, NinNumberType} from "@digita 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)@ +// 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 hold `undefined` on error. -On success, it contains `gender`, `dateOfBirth`, `numberType`, and `isTestNumber`. +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 hold `undefined` on success. +The `error` key will contain a `NinValidationError` on error, and be `undefined` on success. ### The NinInfo type @@ -53,7 +53,7 @@ One of the `NinNumberType` values. This is a Typescript enum, backed by a string #### Test numbers This flag is set to true if the number originates from ["Tenor"](https://www.skatteetaten.no/skjema/testdata/), 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. +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. ### The NinValidationError type diff --git a/package-lock.json b/package-lock.json index 4b406d9..3db193d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,14 @@ { - "name": "nin-validator", + "name": "@digitalarkivet/nin-validator", + "version": "0.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "nin-validator", + "name": "@digitalarkivet/nin-validator", + "version": "0.2.1", + "license": "MIT", "devDependencies": { - "@tsconfig/node16": "^1.0.3", "@types/jest": "^28.1.4", "@typescript-eslint/eslint-plugin": "^5.30.5", "eslint": "^8.19.0", @@ -1068,12 +1070,6 @@ "@sinonjs/commons": "^1.7.0" } }, - "node_modules/@tsconfig/node16": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", - "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", - "dev": true - }, "node_modules/@types/babel__core": { "version": "7.1.19", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", @@ -6008,12 +6004,6 @@ "@sinonjs/commons": "^1.7.0" } }, - "@tsconfig/node16": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", - "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", - "dev": true - }, "@types/babel__core": { "version": "7.1.19", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", diff --git a/package.json b/package.json index 3e30902..a79fa1f 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,31 @@ { "name": "@digitalarkivet/nin-validator", - "version": "0.2.0", + "version": "0.2.1", "description": "Validating and parsing norwegian national identity numbers in Typescript", "author": "Arkivverket", "homepage": "https://github.com/arkivverket/nin-validator", + "repository": { + "type": "git", + "url": "git+https://github.com/arkivverket/nin-validator.git" + }, "bugs": { "url": "https://github.com/arkivverket/nin-validator/issues" }, "license": "MIT", - "private": true, - "main": "dist/nin-validator.js", - "types": "dist/nin-validator.d.ts", + "main": "build/nin-validator.js", + "types": "build/nin-validator.d.ts", + "files": [ + "/build", + "/README.md", + "/LICENSE" + ], "scripts": { "test": "TZ=UTC jest", "prepare": "husky install", "precommit": "lint-staged", "lint": "eslint", "build": "tsc --build tsconfig.dist.json", - "postinstall": "npm run build" + "prepack": "npm run lint && npm run test && npm run build" }, "lint-staged": { "*.{ts,js}": [ @@ -26,9 +34,9 @@ ] }, "dependencies": { - "typescript": "^4.7.4" }, "devDependencies": { + "typescript": "^4.7.4", "@types/jest": "^28.1.4", "@typescript-eslint/eslint-plugin": "^5.30.5", "eslint": "^8.19.0", diff --git a/src/nin-validator.ts b/src/nin-validator.ts index 3a6c5d2..f32ac73 100644 --- a/src/nin-validator.ts +++ b/src/nin-validator.ts @@ -1,3 +1,11 @@ +/* + * Nin-validator + * (c) 2022 Arkivverket + * + * Validator/parser for norwegian national identity numbers. + * Released under the MIT license, see LICENSE file for details + */ + /** * Possible errors when parsing/validating a nin. */ diff --git a/tsconfig.dist.json b/tsconfig.dist.json index 2484759..cd10ea6 100644 --- a/tsconfig.dist.json +++ b/tsconfig.dist.json @@ -3,6 +3,6 @@ "exclude": [ "test", "node_modules", - "dist" + "build" ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index d4e1825..b5a5298 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,12 +11,12 @@ "moduleResolution": "node", "declaration": true, "noImplicitAny": true, - "outDir": "./dist/", + "outDir": "./build/", "allowJs": false, "baseUrl": "src", }, "exclude": [ "node_modules", - "dist" + "build" ] } \ No newline at end of file