Closed sebadob closed 5 days ago
So the error happens when we are generating the code for error insertion. It sees:
err.add_param(::std::borrow::Cow::from("min"), &1672527600);
err.add_param(::std::borrow::Cow::from("max"), &4070905200);
and somehow Rust thinks they are i32?!
Yes it seems like that. As soon as I removed the max
there, the compiler was happy.
Looks like it's defaulting to i32
after not being able to infer a type for T: Serialize
. The easiest fix is to use the i64
suffix:
#[derive(Debug, Serialize, Deserialize, Validate)]
pub struct MyRequest {
#[validate(range(min = 1672527600i64, max = 4070905200i64))]
pub value: Option<i64>,
}
I don't think there's a way to correctly handle i64
and f64
at the same time without providing the type explicitly.
I just commited to finally migrating away from v0.16 and deal with all the errors.
I was able to fix most of them (so far) but now found another bug.
I want to validate an input for an
Option<i64>
withmin
andmax
, and get the error, that the max it out of bounds for ani32
, even though the variable is ani64
.A stripped down version of my struct:
The compiler yells at me that
4070905200
is out of range for ani32
, but there is noi32
: