yajjsl
v1.0.3-r1
Published
yet another javascript json schema library
Maintainers
Readme
Yet Another Javascript Json Schema Library (...hehe)

Yet another piece of code that tries to validate json based on types, this is NOT BASED ON THE JSON SCHEMA STANDARD which I find too verbose for my likes but that's just me. YET REJOICE BECAUSE THE OUTPUT IS MONADIC !!!!
Goals of this Library
- To provide type validation for entities inside a json object
- To provide checkif-empty/undefined validation for entities inside a json object
- The output of this will be the first error encountered (Wrapped in a Left) or the whole object (wrapped in a Right) aka monadic (Either Monad)
Install
npm install yajjsl
Development Goals
- Use Applictive-functors/Monads and it's related operations to make for readable code
- Use Ramda.js for other other operations
- Test library thoroughly
Example
const schema1 = {
"weapon": "String",
"pokemon": Tuple("Array", "String"),
"pokeball": {
"material": "String",
"cost": "Number"
},
"characters": Tuple("Array", {"name": "String"})
};
const incorrect1 = {
"pokemon": [1, 2],
"pokeball": {
"material": ["Egg Nut", "Brown Nut"],
"cost": 100
},
"characters": [{ "name": "Red Foreman"},
{ "name": "I am Fez" }]
};
validate(incorrect1, schema1);
// output -> Left(Tuple("weapon", undefined))
// tuples are based on fantasy-land-tuples
Left Output
// note I use Tuple and Tuple2 interchangebly
Left(Tuple("key", undefined)) // -> "key" field is undefined
Left(Tuple("key", false)) // -> "key" has failed schema-based-validation
Left(Tuple("key", "empty")) // -> "key" has an empty element ({} or [])
Left(Tuple("Schema","invalid")) // -> schema given is invalid
What this is not
- An uber fast library
P.S
- This also features schema checking for validity based on some preset rules
- The output is based off fantasy-land compliant stuff so you should be able to use the monadic output in any monadic/ applicative-functorish chains as long as the monads/applicative-functors belong to any fantasy-land compliant library
License
MIT License
