| Crates.io | json_validate_rs |
| lib.rs | json_validate_rs |
| version | 0.3.42 |
| created_at | 2023-04-28 03:29:11.502107+00 |
| updated_at | 2025-08-20 07:09:28.948183+00 |
| description | validate json schema |
| homepage | https://github.com/gzbakku/json_validate_rs |
| repository | https://github.com/gzbakku/json_validate_rs |
| max_upload_size | |
| id | 851144 |
| size | 113,759 |
this is a simple schema validator for json in rust
use json_validate_rs;
use json_validate_rs::validate;
fn main() {
let format = object! {
"name":object! {"type":"string","min":3,"max":6,"errors":object! {
"min":"",
"max":""
}},
"age":object! {"type":"number","min":18,max:112,"errors":object! {
"min":"",
"max":""
}},
"features": object! {type:"array",min:3,max:5,options:["one","two","three"]},
"games": object! {type:"object",min:1,max:5,validate: object! {
dynamic:false,
schema:object!{
"cricket":{type:"object",min:2,max:2,validate:object!{
schema:{
"score":{type:"number",min:1,max:10,options:["2"]},
"city":{type:"string",min:2,max:10}
}
}}
}
}}
};
let data = object! {
"name":"akku",
"age":27,
"features":["one","two","three"],
"games":{
"cricket":{score:2,city:"delhi"},
}
};
let run = validate(
&format,
&data,
"static",
4
);
println!("run : {:?}",run);
}