サンプル
Configure Luxon error handling and distinguish silent invalid object propagation from immediate exceptions using Settings.throwOnInvalid
sha256:b57c3a02647506219a15642c1ba4615bc67c7e74936f7926208302ed8ef855a5
PUBLISHED
L3_CONTRACT_PASS
MIT-0
ケース
- ゴール
- Configure Luxon error handling and distinguish silent invalid object propagation from immediate exceptions using Settings.throwOnInvalid HOW
- パッケージ
- luxon 3.5.0
- 環境
- node
- 作成日
- 2026-08-16T18:38:35Z
よくある思い込み
Parsing an invalid ISO date string or out-of-range calendar date in Luxon throws an Error or rolls over to a valid date.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- DateTime.fromISO with an unparsable string or impossible calendar date does not throw and does not roll over, returning an invalid DateTime object with isValid false and toISO null
- Operations and arithmetic on an invalid DateTime propagate isValid false without throwing, returning NaN for toMillis and null for toISODate
- DateTime.fromObject with month 0 is treated as out of range and invalid rather than wrapping to January or December
- Setting Settings.throwOnInvalid to true switches Luxon from silent invalid object propagation to immediately throwing an Error on invalid parsing, units, or timezones
- Interval.fromDateTimes with end before start creates an invalid Interval with reason 'end before start' rather than throwing unless throwOnInvalid is enabled
ファイル
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9