You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,8 @@ This a monorepo of OBOS' open source frontend modules.
5
5
6
6
## Packages
7
7
8
-
*[format](./packages/format)
9
-
*[validation](./packages/validation)
8
+
*[format](./packages/format) - A collection of formatting methods for 🇳🇴 and 🇸🇪.
9
+
*[validation](./packages/validation) - A collection of validation methods for 🇳🇴 and 🇸🇪.
10
10
11
11
## Contributing
12
12
@@ -34,4 +34,4 @@ pnpm build
34
34
35
35
### Releases and changelogs
36
36
37
-
We use an automated release process based on [changesets](https://github.com/changesets/changesets) and a [Github action](./.github/workflows/release.yml) to version, release and publish the packages. Meaningful changes should be documented by running pnpm changeset and be a part of the pull request. Remember to follow semver.
37
+
We use an automated release process based on [changesets](https://github.com/changesets/changesets) and a [Github action](./.github/workflows/release.yml) to version, release and publish the packages. Meaningful changes should be documented by running `pnpm changeset` and be a part of the pull request. Remember to follow semver.
The methods are "strict" by default, meaning no formatting characters in the input is allowed.
40
-
This is preferrable, for instance when doing server-side validation, where the input is often expected to be a "clean" value.
39
+
The methods are "strict" by default, meaning no formatting characters in the input is allowed. This even applies to separators such as in Swedish national identity numbers.
41
40
42
-
If you want to allow formatting characters in the input, you can pass `allowFormatting: true` in the options object to the method.
41
+
When doing server-side validation, for instance, before insertion into a database, strictness is often preferrable. The value is often expected to be a "clean" value in standardized format.
42
+
43
+
On the client side, formatting characters could be allowed, as they are more user-friendly, for instance, allowing the user to input their phone number in their preferred format.
44
+
45
+
If you want to allow formatting characters in the value, you can pass `allowFormatting: true` in the options object to the method.
* Check digit verification is currently only implemented for Norwegian organization numbers. For Swedish organiation numbers, we only check the length of the input. PRs are welcome to fix this.
65
-
* validateObosMembershipNumber
62
+
### validateNationalIdentityNumber()
63
+
64
+
Validates that the value is a valid national identity number.
65
+
66
+
Validation is done for the both checksum and if the date is a valid date.
67
+
It accepts both fødselsnummer and d-nummer for Norway, and personnummer and samordningsnummer for Sweden.
68
+
69
+
By default, both the short (10 digit) and long (12 digit) format is allowed for Sweden. You can use the `format` option to specify the format to validate.
> Did you know that you cannot assume that the date in the number is person's date of birth? See [Skatteetaten fødselsnummer](https://www.skatteetaten.no/person/folkeregister/identitetsnummer/fodselsnummer/).
96
+
97
+
### validatePhoneNumber()
98
+
99
+
Validates that the value is a valid phone number. Specify`mobileOnly` to only allow mobile numbers.
100
+
101
+
```js
102
+
// 🇳🇴 example
103
+
import { validatePhoneNumber } from '@obosbbl/validation/no';
Validates that the value is a valid OBOS membership number.
146
+
147
+
> [!NOTE]
148
+
> There is no difference between a Norwegian and Swedish OBOS membership number. The method in use is in fact the same one, re-exported for the different locales.
149
+
150
+
```js
151
+
// 🇳🇴 example
152
+
import { validateObosMembershipNumber } from '@obosbbl/validation/no';
0 commit comments