I need to validate string schema format: "date"
or format: "date-time"
to accept only ISO 8601 but also allow empty string "" (the "" requirement should be separately checked using the required schema).
{
"datetime1": {
"type": "string",
"format": "date-time",
}
}
However, the native ajv format parser does not allow empty string "" to pass. How do I make it allow empty string, and still validate ISO 8601?
Do I really have to write my own format checker using ajv.addFormat()
? I also have the same issue for "format": "email"
, where I also need "" to be valid.
Note: I can't modify the schema, so I can't add defaults.