`format` field of json schemas is not being validated
Closed this issue · 1 comments
Larleyt commented
Hello,
When I run Schema.Validate()
on a schema like below, format
field of a property event_time
is being ignored and goes as "valid" even tho datetime is invalid:
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"title": "User Action Event",
"version": "1.0.0",
"required": [
"action",
"event_time",
// etc...
],
"properties": {
"action": {
"type": "string"
"event_time": {
"type": "string",
"format": "date-time"
}
}
}
// etc...
Data example:
{
"action": "send",
"event_time": "someinvalid datetime"
}
// etc...
What is going on? Should I turn on format checking somehow?
santhosh-tekuri commented
in latest specifications, format assertion is not enabled by default. you have to explicitly do Compiler.AssertFormat = true
or use older specification such as draft7 for example: Compler.Draft = jsonschema.Draft7