11use pyo3:: exceptions:: { PyTypeError , PyValueError } ;
22use pyo3:: intern;
33use pyo3:: sync:: GILOnceCell ;
4- use pyo3:: types:: { IntoPyDict , PyDict , PyTuple , PyType } ;
4+ use pyo3:: types:: { IntoPyDict , PyDict , PyString , PyTuple , PyType } ;
55use pyo3:: { prelude:: * , PyTypeInfo } ;
66
77use crate :: build_tools:: { is_strict, schema_or_config_same} ;
@@ -28,7 +28,11 @@ pub fn get_decimal_type(py: Python) -> &Bound<'_, PyType> {
2828 . bind ( py)
2929}
3030
31- fn validate_as_decimal ( py : Python , schema : & Bound < ' _ , PyDict > , key : & str ) -> PyResult < Option < Py < PyAny > > > {
31+ fn validate_as_decimal (
32+ py : Python ,
33+ schema : & Bound < ' _ , PyDict > ,
34+ key : & Bound < ' _ , PyString > ,
35+ ) -> PyResult < Option < Py < PyAny > > > {
3236 match schema. get_item ( key) ? {
3337 Some ( value) => match value. validate_decimal ( false , py) {
3438 Ok ( v) => Ok ( Some ( v. into_inner ( ) . unbind ( ) ) ) ,
@@ -77,11 +81,11 @@ impl BuildValidator for DecimalValidator {
7781 allow_inf_nan,
7882 check_digits : decimal_places. is_some ( ) || max_digits. is_some ( ) ,
7983 decimal_places,
80- multiple_of : validate_as_decimal ( py, schema, "multiple_of" ) ?,
81- le : validate_as_decimal ( py, schema, "le" ) ?,
82- lt : validate_as_decimal ( py, schema, "lt" ) ?,
83- ge : validate_as_decimal ( py, schema, "ge" ) ?,
84- gt : validate_as_decimal ( py, schema, "gt" ) ?,
84+ multiple_of : validate_as_decimal ( py, schema, intern ! ( py , "multiple_of" ) ) ?,
85+ le : validate_as_decimal ( py, schema, intern ! ( py , "le" ) ) ?,
86+ lt : validate_as_decimal ( py, schema, intern ! ( py , "lt" ) ) ?,
87+ ge : validate_as_decimal ( py, schema, intern ! ( py , "ge" ) ) ?,
88+ gt : validate_as_decimal ( py, schema, intern ! ( py , "gt" ) ) ?,
8589 max_digits,
8690 }
8791 . into ( ) )
0 commit comments