Skip to content

Commit

Permalink
Merge pull request #51 from Johannestegner/master
Browse files Browse the repository at this point in the history
hotfix: Regex allowing | (pipe).
  • Loading branch information
rasmusbe authored Oct 28, 2021
2 parents 8b1d80c + 26adf77 commit f2cd1aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/personnummer/Personnummer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class Personnummer implements Comparable<Personnummer> {
private static final Pattern regexPattern;

static {
regexPattern = Pattern.compile("^(\\d{2})?(\\d{2})(\\d{2})(\\d{2})([-|+]?)?((?!000)\\d{3})(\\d?)$");
regexPattern = Pattern.compile("^(\\d{2})?(\\d{2})(\\d{2})(\\d{2})([-+]?)?((?!000)\\d{3})(\\d?)$");
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/PersonnummerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public void testConstructorCoord(PersonnummerData ssn) {
@ParameterizedTest
@MethodSource({"DataProvider#getInvalidPersonnummer", "DataProvider#getValidCoordinationNumbers"})
public void testConstructorInvalid(PersonnummerData ssn) {
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.longFormat, new Options(false)));
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.shortFormat, new Options(false)));
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.separatedFormat, new Options(false)));
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.separatedFormat, new Options(false)));
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.longFormat, new Options(false)), ssn.longFormat);
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.shortFormat, new Options(false)), ssn.shortFormat);
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.separatedFormat, new Options(false)), ssn.separatedFormat);
assertThrows(PersonnummerException.class, () -> new Personnummer(ssn.separatedLong, new Options(false)), ssn.separatedLong);
}

@ParameterizedTest
Expand Down

0 comments on commit f2cd1aa

Please sign in to comment.