TOML parser: out-of-range datetime/date/time field values not rejected (original) (raw)

Summary

The toml-test invalid corpus has 29 fixtures across datetime/, local-date/, local-datetime/, and local-time/ with field values like 2021-02-29, 2021-02-30, 2021-13-01, 2021-01-32, 12:60:00, 25:00:00, etc. The current parser accepts all of them.

Reproduction

Examples that should fail but currently succeed:

Spec citation

TOML 1.0.0 ยง "Date-Time": values must conform to RFC 3339, which requires field values to be in valid calendar / clock ranges (and Feb 29 only in leap years).

Likely fix

With TomlReadFeature.PARSE_JAVA_TIME enabled the java.time.* parsers already perform this validation. Without it (the default, where datetimes round-trip as strings), TomlParser.parseDateTime should still validate via the same parsers and discard the result, or use a lightweight per-field range check.