From e4c6cf047aa0a594f4250f61e98c66def24e8fcb Mon Sep 17 00:00:00 2001 From: lindangcdrom <130278973+lindangcdrom@users.noreply.github.com> Date: Fri, 15 Dec 2023 08:52:17 +0000 Subject: [PATCH] fix: testDate to identify invalid date and leap year * Fix testDate to identify invalid date and leap year * Refine importation --- .../schema/JsonSchemaOptionsConverter.java | 3 -- .../json/schema/OutputUnitConverter.java | 2 - .../io/vertx/json/schema/impl/Format.java | 12 ++++- .../unsupported-tck-tests.properties | 51 ------------------- 4 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/main/generated/io/vertx/json/schema/JsonSchemaOptionsConverter.java b/src/main/generated/io/vertx/json/schema/JsonSchemaOptionsConverter.java index 0b33ceb8..d2240fb8 100644 --- a/src/main/generated/io/vertx/json/schema/JsonSchemaOptionsConverter.java +++ b/src/main/generated/io/vertx/json/schema/JsonSchemaOptionsConverter.java @@ -1,10 +1,7 @@ package io.vertx.json.schema; import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; import java.util.Base64; /** diff --git a/src/main/generated/io/vertx/json/schema/OutputUnitConverter.java b/src/main/generated/io/vertx/json/schema/OutputUnitConverter.java index 1328bd42..431f589e 100644 --- a/src/main/generated/io/vertx/json/schema/OutputUnitConverter.java +++ b/src/main/generated/io/vertx/json/schema/OutputUnitConverter.java @@ -3,8 +3,6 @@ import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonArray; import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; import java.util.Base64; /** diff --git a/src/main/java/io/vertx/json/schema/impl/Format.java b/src/main/java/io/vertx/json/schema/impl/Format.java index c3ac2029..048da3d9 100644 --- a/src/main/java/io/vertx/json/schema/impl/Format.java +++ b/src/main/java/io/vertx/json/schema/impl/Format.java @@ -1,5 +1,7 @@ package io.vertx.json.schema.impl; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.regex.Pattern; public class Format { @@ -209,6 +211,14 @@ private static boolean testTime(String value) { private static final Pattern FASTDATE = Pattern.compile("^\\d\\d\\d\\d-[0-1]\\d-[0-3]\\d$"); private static boolean testDate(String value) { - return FASTDATE.matcher(value).find(); + if (!FASTDATE.matcher(value).matches()) { + return false; + } + try { + DateTimeFormatter.ISO_DATE.parse(value); + return true; + } catch (DateTimeParseException e) { + return false; + } } } diff --git a/src/test/resources/unsupported-tck-tests.properties b/src/test/resources/unsupported-tck-tests.properties index e8013190..337c5f43 100644 --- a/src/test/resources/unsupported-tck-tests.properties +++ b/src/test/resources/unsupported-tck-tests.properties @@ -24,23 +24,6 @@ draft2019-09/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/EM\ S draft2019-09/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/latin-1\ non-breaking-space\ matches=skip draft2019-09/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/paragraph\ separator\ matches\ (line\ terminator)=skip draft2019-09/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/zero-width\ whitespace\ matches=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/2021\ is\ not\ a\ leap\ year=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 29\ days\ in\ February\ (normal)=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 30\ days\ in\ February\ (leap)=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ April=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ June=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ November=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ September=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ August=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ December=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ January=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ July=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ March=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ May=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ October=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ invalid\ month=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/invalid\ month-day\ combination=skip -draft2019-09/optional/format/date/validation\ of\ date\ strings/invalid\ month=skip draft2019-09/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ e-mail\ address=skip draft2019-09/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ idn\ e-mail\ address=skip draft2019-09/optional/format/idn-hostname/validation\ of\ internationalized\ host\ names/a\ host\ name\ with\ a\ component\ too\ long=skip @@ -126,23 +109,6 @@ draft2020-12/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/EM\ S draft2020-12/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/latin-1\ non-breaking-space\ matches=skip draft2020-12/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/paragraph\ separator\ matches\ (line\ terminator)=skip draft2020-12/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/zero-width\ whitespace\ matches=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/2021\ is\ not\ a\ leap\ year=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 29\ days\ in\ February\ (normal)=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 30\ days\ in\ February\ (leap)=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ April=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ June=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ November=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ September=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ August=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ December=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ January=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ July=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ March=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ May=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ October=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ invalid\ month=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/invalid\ month-day\ combination=skip -draft2020-12/optional/format/date/validation\ of\ date\ strings/invalid\ month=skip draft2020-12/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ e-mail\ address=skip draft2020-12/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ idn\ e-mail\ address=skip draft2020-12/optional/format/idn-hostname/validation\ of\ internationalized\ host\ names/a\ host\ name\ with\ a\ component\ too\ long=skip @@ -226,23 +192,6 @@ draft7/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/EM\ SPACE\ draft7/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/latin-1\ non-breaking-space\ matches=skip draft7/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/paragraph\ separator\ matches\ (line\ terminator)=skip draft7/optional/ecmascript-regex/ECMA\ 262\ \\s\ matches\ whitespace/zero-width\ whitespace\ matches=skip -draft7/optional/format/date/validation\ of\ date\ strings/2021\ is\ not\ a\ leap\ year=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 29\ days\ in\ February\ (normal)=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 30\ days\ in\ February\ (leap)=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ April=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ June=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ November=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 31\ days\ in\ September=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ August=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ December=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ January=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ July=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ March=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ May=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ 32\ days\ in\ October=skip -draft7/optional/format/date/validation\ of\ date\ strings/a\ invalid\ date\ string\ with\ invalid\ month=skip -draft7/optional/format/date/validation\ of\ date\ strings/invalid\ month-day\ combination=skip -draft7/optional/format/date/validation\ of\ date\ strings/invalid\ month=skip draft7/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ e-mail\ address=skip draft7/optional/format/idn-email/validation\ of\ an\ internationalized\ e-mail\ addresses/an\ invalid\ idn\ e-mail\ address=skip draft7/optional/format/idn-hostname/validation\ of\ internationalized\ host\ names/a\ host\ name\ with\ a\ component\ too\ long=skip