Skip to content

Commit

Permalink
chore: minor doc improvements to national id validators (#4118)
Browse files Browse the repository at this point in the history
  • Loading branch information
langz authored Oct 11, 2024
1 parent 1ba2b3a commit 7bb0c23
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { NationalIdentityNumberProperties } from '@dnb/eufemia/src/extensions/fo

## Validators

### Internal validators exposed

`Field.NationalIdentityNumber` expose the following validators through its `validator` and `onBlurValidator` property:

- `dnrValidator`: validates a D number.
Expand All @@ -27,6 +29,8 @@ import { NationalIdentityNumberProperties } from '@dnb/eufemia/src/extensions/fo
- validates the identification number as a D number when first digit is 4 or greater (because a D number has its first number increased by 4).
- validates the identification number as a national identity number (fødselsnummer) when first digit is 3 or less.

### createMinimumAgeValidator

You can create your own age validator by using the `createMinimumAgeValidator` function. It takes an age as a parameter and returns a validator function. The validator function takes a value and returns an error message if the value is not above the given age.
It validates if the identification number has a date of birth that is 18 years or older. It uses only the 7 first digits of the identification number to validate. The first 6 digits representing the birth of date, and the next digit represents the century.
As it only use the 7 first digits, it does not validate the identification number, therefore it's quite common to use this validator together with one of the validators above (`dnrValidator`, `fnrValidator` or `dnrAndFnrValidator`) to validate the identification number as well.
Expand Down

0 comments on commit 7bb0c23

Please sign in to comment.