-
Notifications
You must be signed in to change notification settings - Fork 5
Add donor country ID #372
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
base: master
Are you sure you want to change the base?
Add donor country ID #372
Changes from all commits
1ba196a
eaeaedd
4bf3241
402c031
7c9d667
0e3a7ca
fb8953c
e8e27d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ export enum PersonalDetailsValidation { | |
| VALID_FIELD = "VALID_FIELD", | ||
| NAME_TOO_SHORT = "NAME_TOO_SHORT", | ||
| FULL_NAME_TOO_LONG = "FULL_NAME_TOO_LONG", | ||
| ID_INVALID = "ID_INVALID", | ||
| ID_HAS_NANS = "ID_HAS_NANS", | ||
| PHONE_INVALID = "PHONE_INVALID", | ||
| PHONE_HAS_NANS = "PHONE_HAS_NANS", | ||
| REQUIRED_FIELD = "REQUIRED_FIELD", | ||
|
|
@@ -20,6 +22,11 @@ export type LastNameValidation = | |
| | PersonalDetailsValidation.NAME_TOO_SHORT | ||
| | PersonalDetailsValidation.FULL_NAME_TOO_LONG; | ||
|
|
||
| export type CountryIdNumberValidation = | ||
| | PersonalDetailsValidation.VALID_FIELD | ||
| | PersonalDetailsValidation.ID_INVALID | ||
| | PersonalDetailsValidation.ID_HAS_NANS; | ||
|
|
||
| export type PhoneValidation = | ||
| | FieldValidation | ||
| | PersonalDetailsValidation.PHONE_INVALID | ||
|
|
@@ -46,6 +53,18 @@ export const ValidateLastName = ( | |
| return PersonalDetailsValidation.VALID_FIELD; | ||
| }; | ||
|
|
||
| export const ValidateIdNumber = (id: string): CountryIdNumberValidation => { | ||
| const allNumbersValidator = /^[0-9]*$/; | ||
| if (!allNumbersValidator.test(id)) { | ||
| return PersonalDetailsValidation.ID_HAS_NANS; | ||
| } | ||
| const formatValidator = /^\d{9}$/; | ||
| if (id.length > 0 && !formatValidator.test(id)) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to go all the way, you can also check the "check digit" (ספרת ביקורת).
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| return PersonalDetailsValidation.ID_INVALID; | ||
| } | ||
| return PersonalDetailsValidation.VALID_FIELD; | ||
| }; | ||
|
|
||
| export const ValidatePhone = (phone: string): PhoneValidation => { | ||
| if (!phone) return PersonalDetailsValidation.REQUIRED_FIELD; | ||
|
|
||
|
|
||
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.
Please add tests to cover all cases
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.
added