From 3724a38db4a8ab11cde68d8dbd3444e5bbfde379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tegn=C3=A9r?= Date: Wed, 8 Mar 2023 22:55:03 +0100 Subject: [PATCH] feat: Length check on input. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Tegnér --- .../java/dev/organisationsnummer/Organisationsnummer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/dev/organisationsnummer/Organisationsnummer.java b/src/main/java/dev/organisationsnummer/Organisationsnummer.java index c88df6d..0f06129 100644 --- a/src/main/java/dev/organisationsnummer/Organisationsnummer.java +++ b/src/main/java/dev/organisationsnummer/Organisationsnummer.java @@ -152,6 +152,10 @@ public int compareTo(Organisationsnummer other) { } private void innerParse(String input) throws OrganisationsnummerException { + if (input.length() > 13 || input.length() < 10) { + throw new OrganisationsnummerException("Input value too " + (input.length() > 13 ? "long" : "short")); + } + try { Matcher matches = regexPattern.matcher(input); if (!matches.find()) {