Loading

JSON schema validation does not validate date or time fields

Publiseringsdato: Jul 18, 2025
Løsning

SYMPTOM

You are using the JSON schema validator. Your schema defines date and time fields as below:
"myDate" 
{ 
  "$id": "#/properties/myDate", 
  "type": "string", 
  "format": "date" 
} ​​​
An exception is not raised  when the field contains an invalid date.

CAUSE

The JSON validator the runtime uses is json-schema-validator (https://github.com/java-json-tools/json-schema-validator) and it is based in this specification: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-7.3.1 
It can be verified that the specification does not support the date or time format, it supports date-time instead. 

SOLUTION

This is a works as designed behaviour. In case you need to validate a date or time case, the recommendation is to complete the dates and times in order to be validated as a date-time.
Knowledge-artikkelnummer

001123466

 
Laster
Salesforce Help | Article