Skip to content

Commit bb29d3d

Browse files
committed
changeset
1 parent 175f9ec commit bb29d3d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.changeset/tiny-bobcats-buy.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@obosbbl/validation": patch
3+
---
4+
5+
add method `no/validateAccountNumber()`
6+
7+
Validates that the input is a valid Norwegian national identity number (either a fødselsnummer or a D-nummer).
8+
It validates the checksum and checks if the date of birth is valid.
9+
10+
```
11+
import { validateAccountNumber } from "@obosbbl/validation/no";
12+
13+
validateAccountNumber('12345678903') // => true
14+
15+
```

packages/validation/src/no.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export function validateNationalIdentityNumber(
160160
return isValidDate(year, month, day);
161161
}
162162

163-
export function validateBankAccountNumber(value: string): boolean {
163+
export function validateAccountNumber(value: string): boolean {
164164
// Norwegian bank account numbers use mod 11 with one control digits.
165165
// The first one is calculated for all 11 digits
166166
return mod11(value, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]);

packages/validation/src/validation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('no', () => {
5454
['95230820052', false],
5555
['9523.08.20059', false],
5656
])('validateAccountNumber(%s) -> %s', (input, expected) => {
57-
expect(no.validateBankAccountNumber(input)).toBe(expected);
57+
expect(no.validateAccountNumber(input)).toBe(expected);
5858
});
5959

6060
test.each([

0 commit comments

Comments
 (0)