Converts cast values into JSON-compatible values for JSON Schema validation.
It handles dates, datetimes, enums, custom types, and nested objects and arrays.
Summary
Functions
Converts validated field values into a JSON-compatible map.
Converts a single value into a JSON-compatible value based on its type.
Functions
@spec project([ExParamsSchema.Definition.Field.t()], map()) :: map()
Converts validated field values into a JSON-compatible map.
Omits nil values for optional fields from the output.
iex> fields = ExParamsSchema.Definition.compile_fields!([
...> {:published_on, :date, []},
...> {:label, :string, [optional: true]}
...> ])
iex> ExParamsSchema.Schema.Projector.project(fields, %{published_on: ~D[2026-07-23], label: nil})
%{"published_on" => "2026-07-23"}
@spec project_value( ExParamsSchema.Definition.Field.normalized_type(), ExParamsSchema.value() ) :: ExParamsSchema.value()
Converts a single value into a JSON-compatible value based on its type.
iex> ExParamsSchema.Schema.Projector.project_value({:array, :date, []}, [~D[2026-07-22]])
["2026-07-22"]