Skip to content

Commit 49079d8

Browse files
committed
QA fixes
1 parent 8495474 commit 49079d8

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.changeset/tiny-bobcats-buy.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
add method `no/validateAccountNumber()`
66

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.
7+
Validates that the input is a valid Norwegian bank account number.
98

109
```
1110
import { validateAccountNumber } from "@obosbbl/validation/no";

packages/validation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ import { validateObosMembershipNumber } from '@obosbbl/validation/se';
157157
validateObosMembershipNumber('0000000') // => true
158158
```
159159

160-
### validateBankAccountNumber()
160+
### validateAccountNumber()
161161

162162
Validates that the value is a valid organization number. Validates the checksum of the number.
163163

packages/validation/src/no.ts

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

163-
export function validateAccountNumber(value: string): boolean {
163+
type AccountNumberOptions = ValidatorOptions;
164+
165+
/**
166+
* Validates that the input value is a Norwegian bank account number (kontonummer).
167+
*
168+
* It validates the control digit.
169+
*
170+
* @example
171+
* ```
172+
* validateAccountNumber('XXXXXXXXXXX') // => true
173+
* ```
174+
*/
175+
export function validateAccountNumber(
176+
value: string,
177+
options: AccountNumberOptions = {},
178+
): boolean {
179+
if (options.allowFormatting) {
180+
// biome-ignore lint/style/noParameterAssign:
181+
value = stripFormatting(value);
182+
}
183+
164184
// Norwegian bank account numbers use mod 11 with one control digits.
165185
// The first one is calculated for all 11 digits
166186
return mod11(value, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]);

0 commit comments

Comments
 (0)