-
Notifications
You must be signed in to change notification settings - Fork 20
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
118 pesel validation #140
118 pesel validation #140
Conversation
const required = value => (value ? undefined : "Required"); | ||
|
||
const composeValidators = (required, validator) => value => { | ||
if (typeof validator === "undefined") return required(value); | ||
return validator(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.
Maybe can we move all validators + composeValidators into one file?
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.
I've moved validators and composeValidators into one file.
src/utils/DataHelper.js
Outdated
|
||
if (checkSum !== +pesel.substring(10, 11)) return "Invalid PESEL"; | ||
|
||
return undefined; |
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.
Is there required? I guess if a function has no return at the end by default return undefined
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.
Yes, you are right. If function has no return
, it returns undefined
by default.
return
has been removed from this function.
@@ -0,0 +1,21 @@ | |||
const required = value => (value ? undefined : "Required"); | |||
|
|||
export const isPeselValid = pesel => { |
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 a few unittests for checking if validators work are as expected.
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.
Just create separated file e.g. validators.test.js
and call a function with parameters.
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.
Test file with pesel validator test cases have been added.
Conditions work correctly. |
Added PESEL validator in form based on #118 .
Implemented conditions to enable the user to click "DALEJ" button: