Skip to main content

check_max_length

Function check_max_length 

Source
pub fn check_max_length(value: &str, max: usize) -> Result<(), ValidationError>
Expand description

Rejects a string longer than max characters.

OCPP states maxLength in characters and Rust measures strings in bytes, so this counts chars: a field bounded at 20 accepts twenty non-ASCII characters, as the specification intends, even though they occupy more than twenty bytes.