Releases: code-obos/public-frontend-modules
@obosbbl/[email protected]
Patch Changes
-
bb45e14: add method
no/validateAccountNumber()
Validates that the input is a valid Norwegian bank account number.
import { validateAccountNumber } from "@obosbbl/validation/no"; validateAccountNumber('12345678903') // => true
@obosbbl/[email protected]
Minor Changes
-
1dfc896: add method
no/validateNationalIdentityNumber()
Validates that the input is a valid Norwegian national identity number (either a fødselsnummer or a D-nummer).
It validates the checksum and checks if the date of birth is valid.import { validateNationalIdentityNumber } from "@obosbbl/validation/no"; // Fødselsnummer validatePersonalIdentityNumber('21075417753') // => true // D-nummer validatePersonalIdentityNumber('53097248016') // => true
-
2491f32: add method
se/validateNationalIdentityNumber()
Validates that the input is a valid Swedish national identity number (either a personnummer or a samordningsnummer).
It validates the checksum and checks if the date of birth is valid.It supports both short (10 digits) and long (12 digits) formats, with a separator if the
allowFormatting
option is set totrue
.import { validateNationalIdentityNumber } from "@obosbbl/validation/se"; // short validatePersonalIdentityNumber('YYMMDDXXXX') // true // short with separator validatePersonalIdentityNumber('YYMMDD-XXXX', { allowFormatting: true }) // true // long validatePersonalIdentityNumber('YYYYMMDDXXXX') // true // long input, validate short format validatePersonalIdentityNumber('YYYYMMDDXXXX', { format: 'short' }) // false
Patch Changes
- b1c13ed: add checksum validation of Swedish organization numbers. Previously we only checked the length of the number.
@obosbbl/[email protected]
Patch Changes
-
2cfe3be: fix formatting of Swedish phone numbers that start with the area code 010
Previously it didn't recognize 010 as a 3 digit area code, so the format would be wrong.
// before formatPhoneNumber("010-1234567"); // -> 0101-23 45 67 // after formatPhoneNumber("010-1234567"); // -> 010-123 45 67
@obosbbl/[email protected]
Patch Changes
-
3a52b13: allow country code for phone number input in
formatPhoneNumber()
.Previously it was unable to format phone numbers with country codes (+47, +46), now it can.
Note that the country code will not be part of the formatted output.// 🇳🇴 example formatPhoneNumber("+4700000000"); // => '00 00 00 00' // 🇸🇪 example formatPhoneNumber("+46303123456"); // => '0303-12 34 56'
@obosbbl/[email protected]
Minor Changes
- b444dd8: add method
validateObosMembershipNumber()
to validate if the input value is a valid OBOS membership number.
@obosbbl/[email protected]
Minor Changes
- 66676fe: initial release
@obosbbl/[email protected]
Minor Changes
-
a92336d: add default entrypoint for formatting functions.
This makes it easier to support both Norwegian and Swedish formatting in the same project,
but it requires you to specify the wanted locale as an options argument to the method.Example:
// Combined 🇳🇴🇸🇪 example import { formatOrganizationNumber } from "@obosbbl/format"; formatOrganizationNumber("000000000", { locale: "no" }); // => '000 000 000' formatOrganizationNumber("0000000000", { locale: "se" }); // => '000000-0000' // 🇳🇴 only example import { formatOrganizationNumber } from "@obosbbl/format/no"; formatOrganizationNumber("000000000"); // => '000 000 000' // 🇸🇪 only example import { formatOrganizationNumber } from "@obosbbl/format/se"; formatOrganizationNumber("0000000000"); // => '000000-0000'
@obosbbl/[email protected]
@obosbbl/[email protected]
Minor Changes
- a4938b2: initial release