Helper module for Decimal support in Exonerate.
This module provides utilities for checking if decimal mode is enabled at a given schema location and for converting values to Decimal.
Usage
Enable decimal mode with the :decimal option:
# All numeric locations use Decimal arithmetic
Exonerate.function_from_string(:def, :validate, schema, decimal: :all)
# Specific paths use Decimal arithmetic
Exonerate.function_from_string(:def, :validate, schema,
decimal: [at: ["/properties/price", "/properties/amount"]]
)When decimal mode is enabled at a location:
"type": "number"values (float/integer) are converted to Decimal"type": "integer"values are converted to Decimal"type": "string"values are parsed as Decimal (validation error if invalid)- Numeric filters (minimum, maximum, multipleOf, etc.) use Decimal arithmetic
Summary
Functions
Compares two Decimal values. Returns :lt, :eq, or :gt.
Converts a value to Decimal. Returns {:ok, decimal} or {:error, reason}.
Checks if decimal mode is enabled at the given resource/pointer location.
Converts a schema value (from JSON) to Decimal for comparison. Schema values can be numbers or strings.
Computes the remainder of a / b.
Returns Decimal representing zero.
Functions
Compares two Decimal values. Returns :lt, :eq, or :gt.
Converts a value to Decimal. Returns {:ok, decimal} or {:error, reason}.
Checks if decimal mode is enabled at the given resource/pointer location.
Converts a schema value (from JSON) to Decimal for comparison. Schema values can be numbers or strings.
Computes the remainder of a / b.
Returns Decimal representing zero.