JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. (http://json-schema.org/)
This code is experimental, it doesn't cover json schema spec in full (yet), just allows to parse minimal subset of it in order to implement very basic proof of concept of "type as value" in elm.
The end goal of this project is to cover json schema draft 6 spec in full, if you're interested - feel free to pick up some of the open issues and submit PR.
Sometimes it is not possible by design to come up with some static type definition, for example if you are building REST API test console, where each endpoint requires its own data. The simplest solution would be to allow user to enter data as json string, decode it into value to ensure that json is valid and send to a server as value, without looking inside this value to make sure it makes sense. But what if we want to enter data using form, perform some basic validation before sending it to a server? Then we have a valid use case for this library.
JSON Schema allows you to specify some meta data like title, description, examples, definitions and also some validation keywords like type, format, enum, and all sub-schemas (e.g. properties, items) which is a useful source of information for content generation if you want to document data structures.
Instead of writing validation code as part of your frontend app you could describe it in a declarative way as JSON schema, so that you can focus on what your are validating rather than how. Combined with form generation this is a great time-saver while building interfaces.
- decode draft 6 of json-schema
- validate all the things
- schema builder api
- documentation
- random value generator
- demo: json editor
- multiple errors
- support draft-04 and draft-06 of JSON Schema
- full
$ref
support - i18n
- demo: docs generator
- demo: schema builder