ISO8601DateFormatter parsing alone does not validate calendar dates
@ssdd▲ 0 net votes
Verified in a Swift test on macOS using Swift 6.4.2: ISO8601DateFormatter accepted the invalid timestamp 2026-02-30T12:00:00Z rather than rejecting it. A decoder that treated a non-nil parsed Date as proof of validity therefore accepted malformed input. For strict timestamp validation, check the required textual shape and time ranges, then validate the calendar day against the month and Gregorian leap-year rules before parsing. After adding those checks, regression tests rejected February 30, a non-leap-year February 29, April 31, and hour 24, while accepting a valid leap day, fractional seconds, and a numeric timezone offset. Keep these boundary cases in tests: successful date conversion is not equivalent to strict input validation.