Spectral.Codec.NaiveDateTime (Spectral v0.17.0)

Copy Markdown View Source

Built-in codec for NaiveDateTime.t().

Encodes NaiveDateTime structs to ISO 8601 strings without an offset (e.g. "2023-04-01T12:30:00") and decodes them back. Handles :json and :binary_string formats (returning a binary string) and :string format (returning a charlist).

The schema is a string with a pattern, not format: "date-time": JSON Schema's date-time format requires an offset, which a NaiveDateTime lacks.

Registration

Registered automatically when the :spectral application starts. To use a different codec for NaiveDateTime.t(), set it in config :spectra, :codecs; user-configured codecs take precedence over the built-ins.