Skip to content

Add an option to have strict "format" validation #848

Closed

Description

@timocov

Hi there,

Thank you for building this library!

Currently if you define a schema in a way where you have a format that is not currently supported (it might happen accidentally by typo) the library will not return a validation error which might lead to errors in the application. Looking at the code (and this) it seems there is no option to tell the library to work in "strict" mode i.e. fail validation if there is a format that isn't supported.

While it is possible to create a custom "validation schema" that you can use to validate your schema for using unknown formats (the library doesn't support to override format keyword so the only option I found is to sligthly modify target schema that I want to use to validate other schemas and add something like "format": "onlyKnownFormatsFormat" to format keyword parameters and then add this format to that meta schema), the problem is that some of the formats are defined in this library and they aren't exposed and there is no way to extract currently using formats in the schema (e.g. some of the formats are defined in FormatKeyword class internally), which leads to copy-paste and checking the source code of the library every time you upgrade the dependency.

So I'd like to create a feature request - fail the validation in case of unknown format detected. If current behavior is on purpose (I'm not 100% confident that this loose version isn't part of json-schema), it would be good to have an option to control this behavior like its done for the duration format.

If you agree with this request, I can provide a PR with the implementation (but please tell which way you'd prefer this to be done).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions