Skip to content
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

Merged

Conversation

damianwojtkowski
Copy link
Contributor

Added PESEL validator in form based on #118 .
Implemented conditions to enable the user to click "DALEJ" button:

  • length - 11 characters,
  • valid check sum with last character of PESEL.

Comment on lines 10 to 14
const required = value => (value ? undefined : "Required");

const composeValidators = (required, validator) => value => {
if (typeof validator === "undefined") return required(value);
return validator(value);
};
Copy link
Member

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?

Copy link
Contributor Author

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.


if (checkSum !== +pesel.substring(10, 11)) return "Invalid PESEL";

return undefined;
Copy link
Member

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

Copy link
Contributor Author

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 => {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@Rafalkufel Rafalkufel merged commit c857466 into CodeForPoznan:master Apr 24, 2020
@AgataSroka
Copy link

AgataSroka commented May 17, 2020

Conditions work correctly.
But comments ("Type PESEL" and "Invalid PESEL") should be written in Polish.
We need to change "Type PESEL" to "Wpisz PESEL" and "Invalid PESEL" to "Nieprawidłowy PESEL".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants