DecimalSchema
This class defines the configuration for validating and serializing decimal values within a schema. It provides options for enforcing numeric constraints such as precision, scale, and range, as well as controlling the acceptance of special values like infinity and NaN.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | Literal['decimal'] | Fixed literal value used to identify the schema as a decimal type. |
| allow_inf_nan | bool = False | whether 'NaN', '+inf', '-inf' should be forbidden. default: False |
| multiple_of | Decimal | Constraint that requires the decimal value to be an exact multiple of this specified value. |
| le | Decimal | Inclusive upper bound constraint that the decimal value must be less than or equal to. |
| ge | Decimal | Inclusive lower bound constraint that the decimal value must be greater than or equal to. |
| lt | Decimal | Exclusive upper bound constraint that the decimal value must be strictly less than. |
| gt | Decimal | Exclusive lower bound constraint that the decimal value must be strictly greater than. |
| max_digits | int | Maximum total number of significant digits allowed in the decimal number. |
| decimal_places | int | Maximum number of digits allowed to the right of the decimal point. |
| strict | bool | Whether to validate the decimal in strict mode, preventing type coercion from non-decimal inputs. |
| ref | str | A unique string identifier used for cross-referencing this schema in recursive or complex definitions. |
| metadata | dict[str, Any] | A dictionary of additional metadata used to store custom configuration or plugin-specific information. |
| serialization | SerSchema | Custom serialization schema defining how the decimal should be converted to other formats. |