Skip to main content

validate_args

Function validate_args 

Source
pub fn validate_args<T: VldParse>(json_str: &str) -> Result<T, VldTauriError>
Expand description

Validate a raw JSON string against a vld schema.

Convenience wrapper — parses the string first, then validates.

§Example

use vld_tauri::validate_args;

vld::schema! {
    #[derive(Debug)]
    struct Ping {
        msg: String => vld::string().min(1),
    }
}

let p = validate_args::<Ping>(r#"{"msg":"pong"}"#).unwrap();
assert_eq!(p.msg, "pong");