vertx-json-schema icon indicating copy to clipboard operation
vertx-json-schema copied to clipboard

Json Schema usage with a custom date-time pattern is not replacing the default date time regex pattern

Open pantinor opened this issue 2 years ago • 0 comments

Questions

Refer to io.vertx.json.schema.common.SchemaImpl which has a list of validators iterated during processing.

https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/main/java/io/vertx/json/schema/common/SchemaImpl.java#L171

https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/main/java/io/vertx/json/schema/common/BaseFormatValidatorFactory.java#L103

Am adding a custom pattern on a date-time property to override the default DATETIME pattern regex, however, when processing, notice that the default BaseFormatValidatorFactory FormatValidator still remains in the validator list along with the custom PatternValidatorFactory PatternValidator that was added.

Is it a bug? Why is the default format validator there, as expected it to be replaced / removed by the custom one.

Version

4.1.2

Context

I encountered an exception which looks suspicious while testing validateSync with a schema.

Do you have a reproducer?

Yes there is a testng but it is in private project, not portable as a public project. But the existing vertx unit test might be enhanced to use a custom date time pattern to see that the default formatter is not removed from the validator list.

Steps to reproduce

Extra

The schema am using is this one:

                "effective-start": {
                    "type": "string",
                    "format": "date-time",
                    "pattern" : "^\\d{4}\\-\\d{2}\\-\\d{2}[\\s]\\d{2}:\\d{2}:\\d{2}"
                }

`

pantinor avatar Dec 12 '22 21:12 pantinor