diff --git a/core/lib/src/form/validate.rs b/core/lib/src/form/validate.rs index 38ebfe37..f5247b24 100644 --- a/core/lib/src/form/validate.rs +++ b/core/lib/src/form/validate.rs @@ -346,6 +346,20 @@ impl> Len for Result<'_, T> { fn zero_len() -> L { T::zero_len() } } +#[cfg(feature = "json")] +impl> Len for crate::serde::json::Json { + fn len(&self) -> L { self.0.len() } + fn len_into_u64(len: L) -> u64 { T::len_into_u64(len) } + fn zero_len() -> L { T::zero_len() } +} + +#[cfg(feature = "msgpack")] +impl> Len for crate::serde::msgpack::MsgPack { + fn len(&self) -> L { self.0.len() } + fn len_into_u64(len: L) -> u64 { T::len_into_u64(len) } + fn zero_len() -> L { T::zero_len() } +} + /// Length validator: succeeds when the length of a value is within a `range`. /// /// The value must implement [`Len`]. On failure, returns an [`InvalidLength`]