-
Notifications
You must be signed in to change notification settings - Fork 0
add validation package #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * https://www.brreg.no/om-oss/registrene-vare/om-enhetsregisteret/organisasjonsnummeret/ | ||
| * https://no.wikipedia.org/wiki/Organisasjonsnummer | ||
| */ | ||
| return mod11(value, [3, 2, 7, 6, 5, 4, 3, 2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/validation/src/se.ts
Outdated
| } | ||
|
|
||
| if (options.mobileOnly) { | ||
| const isMobileNumber = /^07\d{8}$/.test(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evt check på riktnummer för mobil (07X)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swedish mobile phone numbers only have 5 area codes, so we can validate these for further correctness
| return false; | ||
| } | ||
|
|
||
| let sum = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Krem eksempel på en liten reduce? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Det skal sies at var opprinnelig en reduce faktisk, men reduce er en av de tingene jeg har sluttet å bruke. 9/10 ganger er ikke-reduce varianten mer lesbar, imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, må nok si meg uenig her ja 😆
16 år etter at reduce ble introdusert til js så er ikkje det noe "magisk" eller uleselige greier lenger 😉




Denne PRen legger til ny pakke
@obosbbl/validation.Tanken er at den skal inneholde en samling med forskjellige valideringsmetoder som vi har nytte av i OBOS, og at den skal støtte både no og se, på lik linje med @obosbbl/format.
Det vil si at denne pakken blir deprecated etter hvert https://github.com/code-obos/frontend-modules/tree/main/packages/validation.
For nå kommer den innebygget med følgende valideringsmetoder:
Alle metodene tillater en optional param hvor man kan bestemme om formatering skal være tillatt under validering. Merk at dette ikke er tillat by default. Men i noen tilfeller kan det være fornuftig å tillatte dette, feks når brukeren skal fylle ut et skjema og man har lyst til å validere at dataen er riktig, men også lar brukeren bruke sin foretrukne formatering på feks telefonnnummer.