Skip to main content

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

AttributeTypeDescription
typeLiteral['decimal']Fixed literal value used to identify the schema as a decimal type.
allow_inf_nanbool = Falsewhether 'NaN', '+inf', '-inf' should be forbidden. default: False
multiple_ofDecimalConstraint that requires the decimal value to be an exact multiple of this specified value.
leDecimalInclusive upper bound constraint that the decimal value must be less than or equal to.
geDecimalInclusive lower bound constraint that the decimal value must be greater than or equal to.
ltDecimalExclusive upper bound constraint that the decimal value must be strictly less than.
gtDecimalExclusive lower bound constraint that the decimal value must be strictly greater than.
max_digitsintMaximum total number of significant digits allowed in the decimal number.
decimal_placesintMaximum number of digits allowed to the right of the decimal point.
strictboolWhether to validate the decimal in strict mode, preventing type coercion from non-decimal inputs.
refstrA unique string identifier used for cross-referencing this schema in recursive or complex definitions.
metadatadict[str, Any]A dictionary of additional metadata used to store custom configuration or plugin-specific information.
serializationSerSchemaCustom serialization schema defining how the decimal should be converted to other formats.