Skip to content

YumeXi/schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Schema

Schema library provides APIs to parse Schema and to validate Json by parsed Schema.

Usages

What is JSON Schema?

JSON Schema is the vocabulary that enables JSON data consistency, validity, and interoperability at scale.

Parse

Use @lib.parse to parse a JSON Schema.

Validate

You can use @lib.validate to validate a JSON object by a parsed Schema.

TODO

  1. Support for references is being done.
  2. Using options to control some validation behavior is in planning.
  3. Add documentation.

Examples

let schema = @lib.parse!({
    "$id": "example",
    "type": "object",
    "properties": {
        "limited_number": {
            "type": "number",
            "minimum": 0,
            "maximum": 42
        }
    }
})

println(schema.validate({ "limited_number": 23 }).is_ok()) // output: true
println(schema.validate({ "limited_number": 42.1 }).is_ok()) // output: false

Note

The library is WIP! The APIs are unstable and the functionality is not complete.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published