23 releases

0.3.1 Aug 15, 2024
0.2.92 Aug 3, 2024
0.2.91 Jul 12, 2024
0.2.8 Dec 11, 2023
0.1.3 May 8, 2023

#582 in Database interfaces

Download history 20/week @ 2024-08-05 245/week @ 2024-08-12 31/week @ 2024-09-16 31/week @ 2024-09-23 4/week @ 2024-09-30 2/week @ 2024-10-07

1,317 downloads per month

MIT license

75KB
2K SLoC

json_validate_rs

Json validator in rust

this is a simple schema validator for json in rust

supported data types

  • Import a HTML file and watch it magically convert to Markdown
  • Drag and drop images (requires your Dropbox account be linked)
  • Import and save files from GitHub, Dropbox, Google Drive and One Drive
  • Drag and drop markdown and HTML files into Dillinger
  • Export documents as Markdown, HTML and PDF

supported validation types

  • String = min,max,options
  • number = min,max,options
  • array = min,max
  • object = min,max,schema

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);

}

Dependencies

~2.8–4MB
~67K SLoC