Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since 1.3.0: UUID not correctly validated #937

Closed
itineric opened this issue Jan 29, 2024 · 4 comments
Closed

Since 1.3.0: UUID not correctly validated #937

itineric opened this issue Jan 29, 2024 · 4 comments

Comments

@itineric
Copy link

Consider the following schema:

{
  "type": "object",
  "properties":
  {
    "id":
    {
      "type": "string",
      "format": "uuid"
    }
  }
}

Using UUID as defined here:
https://json-schema.org/draft/2019-09/json-schema-validation#rfc.section.7.3.5

Validating the following JSON does not produce an error as expected (with version 1.2.0 it worked)

{
  "id": "not an UUID"
}
@justin-tay
Copy link
Contributor

In version 1.3.0 the format keyword by default complies with the specification that it should be an annotation since 2019-09 and configuration needs to be set to always generate an assertion or the required vocabulary needs to be in the meta schema.

https://json-schema.org/draft/2020-12/json-schema-validation#name-vocabularies-for-semantic-c

@itineric
Copy link
Author

what should I modify in the given example ? Sorry I dont get it.

@justin-tay
Copy link
Contributor

You can set setFormatAssertionsEnabled on the SchemaValidatorsConfig or on a per execution basis.

Set<ValidationMessage> assertions = schema.validate(input, InputFormat.JSON, executionContext -> {
    // By default since Draft 2019-09 the format keyword only generates annotations and not assertions
    executionContext.getConfig().setFormatAssertionsEnabled(true);
});

@rmuller
Copy link

rmuller commented Mar 5, 2024

Should be closed, see #938

@stevehu stevehu closed this as completed May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants