Writing `date` in a JSON Schema does not mean the validator will necessarily check dates

Schema says `format: date`, yet the bad date passed validation; this doesn't necessarily mean the library has a bug. `format` handling depends on the validator's configuration. When you get a "validation succeeded" result, first ask what it actually checked: types, structure, or also date semantics.

Key Points of This Article

  • Having format: date in a schema does not mean the validator will necessarily check date semantics.
  • The default Draft202012Validator performs only structural validation and will not reject non-existent dates such as 2026-02-30.
  • The month/day order of 03/04/2026 must be confirmed by the source region, field documentation, or an explicit agreement; passing date validation does not prove the month was chosen correctly.
  • Tests should include valid leap days, invalid leap days, and malformed values, and verify each one item by item in a locked environment.

JSON Schema has "format: date" written in it, and a nonexistent date passed validation. This is usually not a bug in the library. How "format" is handled depends on the validator's configuration. When you get a "validation succeeded" result, first confirm whether it checks only the type and structure, or also checks date semantics.

This article suits developers and reviewers who need to perform structured validation on document data and care about the accuracy of date fields. After reading it, you should be able to judge what a passing validation actually means, and use counterexample tests to lock down the date rules.

This document uses synthetic samples to demonstrate the processing methods. Before processing important files, keep the original, and review them against the boundaries and acceptance items described in the text.

What does JSON Schema's date format validation actually check? One-sentence answer

First confirm whether the validator has the format check enabled, then confirm whether the semantic rules for dates (whether they actually exist and how they are interpreted) are handled separately by someone else.

Your situationRecommended PracticesCause
Check format: date using only the default validator.First confirm whether FormatChecker is explicitly enabled.format's handling depends on the validator configuration.
Need to identify dates like 2026-02-30Add it to the test set as a counterexample.A string that looks like a date does not mean that date exists on the calendar.
The day and month order of the source date is unclearFlag ambiguity; do not guess automatically.Passing the date validation only means that the converted value is valid.
Field with time and time zoneUse an independent time protocolYou shouldn't just casually take the first ten characters and process them.
For verifying the date of the translation draftSave raw_text and the normalized value at the same timeThe reviewer needs to see both the original content and the system's explanation at the same time.

Two Checks That Look the Same

2026-02-30 is a string whose shape looks like a date, but February has no 30th day. Checking only the regex shape would miss this kind of problem. Below, using Python's jsonschema, we compare the results of the default validator with those of explicitly enabling FormatChecker.

Probing the configuration with an impossible date

from jsonschema import Draft202012Validator, FormatChecker

schema = {"type": "string", "format": "date"}
structural = Draft202012Validator(schema)
strict = Draft202012Validator(schema, format_checker=FormatChecker())

def valid(v, value):
    return not list(v.iter_errors(value))

assert valid(structural, "2026-02-30")
assert not valid(strict, "2026-02-30")
assert valid(strict, "2024-02-29")
assert not valid(strict, "2025-02-29")
assert not valid(strict, "26/09/2026")
assert not valid(strict, 20260926)

The synthetic example only verifies date. Other formats may have optional dependencies or implementation differences, so each one should be tested individually in a locked environment. An unknown format name must not be treated as though some check had actually been implemented; a misspelling could leave you with a false sense of security.

Date format is not a date interpretation rule

The 03/04/2026 in the source may represent March 4 or April 3. Before converting it to ISO format, you need the source region, a field description, or an explicit convention. Passing date validation only shows that the converted value is valid; it cannot prove that you chose the right month.

Source informationWhat should be doneWhat you should not do
Nonexistent calendar dateError report and check the sourceAutomatically scroll to next month
Sun and moon order unknownMark ambiguityGuess based on the server language
With time and time zoneUsing an independent time protocolTake the first ten characters at random.
Field is emptyHandle according to missing-value rulesFill in today's date

Include the configuration in regression testing

The test set should include at least three kinds of values: a valid leap day, an invalid leap day, and a malformatted value. Running these counterexamples at deployment is more effective than merely checking whether the Schema file exists. If the service is implemented across multiple languages, the same test set should be verified separately for each, and you should not assume that the default behavior of the two validators is consistent.

Review of Translation Drafts: Retaining Original Dates

When using the date extraction results for proofreading the OmniDoc translation, it is recommended to save both the raw_text and the normalized values at the same time. Proofreaders need to see both "what the original content is" and "how the system interprets it" in order to pinpoint whether the discrepancy arises in the translation, the extraction, or the format conversion step.

References: JSON Schema String and format.

📊 Core Comparison

Comparison itemDefault validatorExplicitly enable FormatChecker
Scope of inspectionTypes and StructuresAdditional check of the format of the format declaration
Conclusion on 2026-02-30One cannot assume it will be rejected.Needs to be verified empirically with counterexamples
Meaning of "Passing"It does not mean the date semantics are correct.Business date interpretations still need to be verified.

🎯 Which Approach Suits You?

If you only need to confirm that a field is a string or that the structure is correct

The default validator is usually sufficient, but be aware that it does not necessarily check date semantics.

If you need to confirm that a date actually exists

Explicitly enable FormatChecker, and verify with counterexamples such as 2026-02-30.

If you need to verify dates in a source document

First confirm the day-month order convention used by the source, then keep the original text alongside the normalized value.

If your service is deployed across multiple languages

Run the same test suite separately in each implementation.

❓ Frequently Asked Questions (FAQ)

1. Why does the schema pass an invalid date even though it says format: date?

The handling of format depends on the validator configuration; by default, semantic date validity is not necessarily checked.

2. Why is 2026-02-30 a useful test value?

It looks like a date, but February has no 30th day. Checking only the surface form would miss this kind of problem.

3. What happens when you use an unknown format name?

It cannot be treated as though it had been checked, and a misspelling may give you a false sense of security.

4. How should 03/04/2026 be converted?

The source region, a field description, or an explicit convention is needed. Otherwise it is impossible to determine whether it represents March 4 or April 3.

📝 Summary

Passing validation only means the data satisfies the declared rules; it does not mean every date is interpreted correctly. First confirm the validator's scope of checks, then pin down the date handling with counterexamples and source rules, so the results are more reliable.

Try it now: upload a document and start translating right away, with the original layout preserved.

Updated 2026-11-29