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

HV-1970 Add Korean specific RRN annotation #1338

Closed
wants to merge 20 commits into from

Conversation

ing9990
Copy link
Contributor

@ing9990 ing9990 commented Jan 12, 2024

Jira-(HV-1970)

Hai I tried to add Korean specific @rrn annotation.
I added annotation, validator, testcases, messages, etc.

Copy link
Member

@marko-bekhta marko-bekhta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your pull request.

This post on adding new constraints may be interesting to you, if you haven't seen it before: https://in.relation.to/2018/01/04/adding-new-constraint-to-engine/ . See the annotation processor and documentation steps in particular.
Also, maybe you could update the ValidationMessages_ko.properties file with the new message as well?

public class KorRRNValidator implements ConstraintValidator<KorRRN, CharSequence> {

private static final Pattern KOR_RRN_REGEX = Pattern.compile(
"\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])-[1234]\\d{6}$" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is worth to check the check digit for the older numbers?

c, the 13th digit, is a check digit, used to verify that the number has been transcribed correctly. It is generated from the rest of the digits using the following algorithm (digits lettered a through m in order):
m = [11 − {(2a + 3b + 4c + 5d + 6e + 7f + 8g + 9h + 2i + 3j + 4k + 5l) mod 11}] mod 10

Copy link
Contributor Author

@ing9990 ing9990 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is meaning "older number"?

Copy link
Member

@marko-bekhta marko-bekhta Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, for RRNs issued prior to October 2020 the last digit in the number was a check-digit. After that date, it became a random number. So I was asking if it would make sense to validate the check-digit for numbers issued prior to October 2020.

Copy link
Contributor Author

@ing9990 ing9990 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, RRNs are still using check digits after October 2020.
Let's say "RRN" is "ABCDEF-GHIJKLM", then Since October 2020, 'HIJKL' has been changed to a randomized order, but check-digits(M) are valid

Configuration of RRNs
Screenshot 2024-01-15 at 5 09 41 PM

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 checked and the law is ambiguous.

See Government homepage 2020.05

See Government homepage 2020.05

So, I'll check with the government tomorrow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! that would be nice.

Also as an idea: we could try adding an attribute to the constraint annotation:

public @interface KorRRN {
	// ... 
	boolean validateCheckDigit() default true;
}

to make the validation optional. Or take it a step further and:

public @interface KorRRN {
        //...
	ValidateCheckDigit validateCheckDigit() default ValidateCheckDigit.ALWAYS;
	
	enum ValidateCheckDigit {
		NEVER,
		ALWAYS,
		BEFORE_OCTOBER_2020_ONLY
	}
}

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 called the Korean goverment and they said you're right. 😂 This seems like a good idea. So I Updated KorRRN to include "validateCheckDigit"attribute and i added a few test cases.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jan 14, 2024

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

Co-authored-by: Marko Bekhta <[email protected]>
Copy link
Member

@marko-bekhta marko-bekhta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress! I've added a few comments inline.

@ing9990 ing9990 requested a review from marko-bekhta January 19, 2024 00:13
Copy link
Member

@marko-bekhta marko-bekhta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

Thanks for your work! I think we are nearly there. There are a few inline comments, mostly about the style to align things with the existing code. And also, we'd want to add this new constraint to the documentation here:

`@NIP`:: Checks that the annotated character sequence represents a Polish VAT identification number (https://pl.wikipedia.org/wiki/NIP[NIP])

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.

2 participants