Skip to content

Commit

Permalink
Version 0.2.1.
Browse files Browse the repository at this point in the history
- Change output folder to "build"
- Distribute only the compiled .d.ts and .js files
- Clarify licensing
- Remove "private" flag from package.config
  • Loading branch information
slahn committed Aug 16, 2022
1 parent 43be58a commit cb8608d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
build
jest.config.js
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**/.DS_Store
node_modules
dist
build
.vscode
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
20 changes: 5 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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}": [
Expand All @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/nin-validator.ts
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"exclude": [
"test",
"node_modules",
"dist"
"build"
]
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"moduleResolution": "node",
"declaration": true,
"noImplicitAny": true,
"outDir": "./dist/",
"outDir": "./build/",
"allowJs": false,
"baseUrl": "src",
},
"exclude": [
"node_modules",
"dist"
"build"
]
}

0 comments on commit cb8608d

Please sign in to comment.