networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
859 stars 325 forks source link

Schema validate always print "Failed to apply pattern" when validate fail #1105

Closed huntkalio closed 2 months ago

huntkalio commented 2 months ago

When I use schema.validate(stringData, OutputFormat.BOOLEAN) function , it default turn on setFailFast to ture.But if setFailFast is set to ture, it will throw FailFastAssertionException when validate fail. And then it will always print "Failed to apply pattern" due to: - https://github.com/networknt/json-schema-validator/blob/12807f33a19a7981452b8eabf9e1bcdae30df5c6/src/main/java/com/networknt/schema/PatternValidator.java#L68;

Now, I have to config failFast to false to remove the print, but this will impact performance.

When throw FailFastAssertionException exception, may not print ERROR level logs?

justin-tay commented 2 months ago

Thanks for the bug report.

As a workaround you can just disable the log for com.networknt.schema.PatternValidator.

For instance for logback

<logger name="com.networknt.schema.PatternValidator" level="OFF"/>