validate_value_strings_utf8

Function validate_value_strings_utf8 

Source
pub fn validate_value_strings_utf8(value: &DataValue) -> Result<u32, String>
Expand description

Recursively validate UTF-8 in all strings within a DataValue

This function traverses the DataValue structure and counts all strings, verifying they are valid UTF-8. Since DataValue::String already guarantees UTF-8 validity (enforced during decoding), this primarily serves as a structural validator and counter.

§Arguments

  • value - DataValue to validate

§Returns

  • Ok(count) - Number of strings found (all valid UTF-8)
  • Err(msg) - Error message if validation fails

§Note

The DataDecoder already enforces UTF-8 validity when creating String variants, so this function won’t find invalid UTF-8 in properly decoded values. It’s useful for:

  • Counting strings in a structure
  • Detecting decode issues early
  • Providing structural validation