Skip to main content

check

Function check 

Source
pub fn check(format: StringFormat, value: &str) -> Result<(), String>
Expand description

Checks a string against one format, reporting why it failed as prose.

The reason is flattened to a String rather than kept as one enum per format, because the caller is a record validator building a path-prefixed message and has nothing to do with the difference between a bad month and a bad offset beyond repeating it.

use didbot_schema::format::{check, StringFormat};
assert!(check(StringFormat::Datetime, "2024-01-01T00:00:00Z").is_ok());
assert!(check(StringFormat::Did, "123").is_err());