Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noredink/json-elm-schema
https://github.com/noredink/json-elm-schema
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/noredink/json-elm-schema
- Owner: NoRedInk
- License: bsd-3-clause
- Created: 2017-01-20T12:25:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T09:51:44.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T19:03:55.688Z (9 months ago)
- Language: Elm
- Size: 220 KB
- Stars: 45
- Watchers: 6
- Forks: 11
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elm JSON Schema
It's very easy to write a [JSON Schema](http://json-schema.org/) that is valid JSON but not a valid JSON Schema.
Such faulty schema's still work, they'll just be less strict then you think they are.
Usually you'll learn about this a bit later than you'd prefer.Elm-json-schema allows you to write your JSON schema's in Elm, ensuring a valid result.
## Example
```elm
personSchema : Schema
personSchema =
object
[ title "person"
, properties
[ required "firstName" <| string []
, required "lastName" <| string []
, optional "age" <|
integer
[ description "Age in years"
, minimum 0
]
, optional "height" <|
number
[ description "Height in meters"
, minimum 0
]
, required "tags" <|
array
[ items <| string []
, minItems 1
]
]
]
```## Links
- [A fully working example](https://github.com/NoRedInk/json-elm-schema/tree/master/example)
- [A CLI tool for compiling your elm json schemas to regular json schemas](https://github.com/NoRedInk/json-elm-schema/tree/master/cli)