Overview

This is a note about using the following repository to validate JSON:API compliance.

https://github.com/elliotttf/jsonapi-validator

At the time of writing this article, it appears to have not been updated for 7 years, so it may not support the latest schemas, but I was able to perform simple validation.

Usage

I prepared the following repository to try the library above.

https://github.com/nakamura196/jsonapi-validator-demo

Installation

This assumes the use of nvm, but it is not required.

gcnnpidvvntmmpjmcsiulosion2ena2ep2i2h-tvtaplsi:d/a/tgoirt-hduebm.ocom/nakamura196/jsonapi-validator-demo

Testing

Valid Example

{}"}"]j,dsaotn""}a{}avm"pee:irt"sa"}["""}:i"ltiao:iydt{nnp"t"{k"}e:r":ss"it"e:"bi":l1ut1f""0tl.{"hr_ee0:reAs""ec0":,{fo0:"r2":d4{"8",5h3t""t,p://jsonapi.org/format/1.0/"
0/1n_ovdael_imdo.djusloens/ijssovnaalpiid-vJaSlOiNdaAtPoIr.bin/jsonapi-validator.js-f/01_valid.json

Invalid Example: Unnecessary Properties

There is an unnecessary property aaa.

{}"}"}"]j,a,dsaaoatn""}""a{}avm:b"peeb:irt{b"sa"}"["""}:i"l:tiao:iydt{nn"p"t"{k"}ce:r":ssc"it"ec:"bi":l"1ut1f""0tl.{"hr_ee0:reAs""ec0":,{fo0:"r2":d4{"8",5h3t""t,p://jsonapi.org/format/1.0/"
I/nnvssassassassmssassassmssoahcdhcdhcdhcihcdhcdhcihcdlohdohdohdohsohdohdohsoheiueiueiueiuesueiueiuesue_dlmtlmtlmtlmilmtlmtlmilmmdaidaidaidandaidaidandaoJPoPoPoPgPoPoPgPdSNanNanNanhaPNanNanhaPmauOOtaOtaOtaatrOtaOtaatratlNThlThlThlvhoThlThlvhothe:P:P:Pe:p:P:Pe:pc:sAhrhrhrehrhreh/Pa#a#a#r#ra#a#r#r#jIvpvpvpe/tvpvpe/te/s.eaeeaeeaeqryeaeeaeqryxoodrdrdrue:drdrue:annadtadtadtiqadtadtiqceadiydiydiyruediydiyrumtOpdt:dt:dt:eirdt:dt:eielfiiiiiiidrriiiidrty-toatoatodeotoatodeavinainainapdrinainapdoaoaaoaaoatrsoaaoatrnlnlnlnlaonlnlaoeiaPaPaPpaPaPpdlrlrlrelrlresaoooroorctpppppptppppthorerereyrereyerorororororm/ptptpt'ptpt'abeieieieeieimirerererrereeintststsrtststn/iiioiiajeeeree'osssssss.no...'..en.Oafp.i-validator.js-f/02_invalid_additional_properties.json

Invalid Example: Missing Required Properties

This is an example where the required property type is missing.

{}"}"]j,dsaotn""}a{}avm"pee:irt"sa"}[""}:i"liao:idt{nn"t"{k"}:r":ssit"e"bi":l1ut1f"0tl.{"h_ee0:rAs""e0":,{f0:"2":4{8"5h3t""t,p://jsonapi.org/format/1.0/"
I/nnvsstssmsstssssassmssassmssoahcyhcihcyhchcdhcihcdhcihcdlohpohsohpohohdohsohdohsoheiueeuesueeueueiuesueiuesue_dlm:lmilm:lmlmtlmilmtlmilmmdadandadadaidandaidandaoJPoPgPnPPoPgPoPgPdSbabhaPbaumaNanhaPNanhaPmauOetjatretlatOtaatrOtaatratlNhevhohlthThlvhoThlvhotheo:ce:pn:c::Pe:p:Pe:pc:sAbteuhhrehreh/Pj#r#rl##a#r#ra#r#r#jIe/e/tle/vpe/tvpe/te/s.ctqry.oxoeaeqryeaeqryxootyue:nandrue:drue:ann.piqeceadtiqadtiqceaerutOtOdiyruediyrumtOpeiyflfdt:eirdt:eielfidrp/yiidrriidrty-ee2todeotodeavpd/oinapdrinapdoartnoatrsoatrnloyenlaonlaoeippaPpaPpdeeslrelresarcororctthpptppthoyereyreyermororm/'apt'pt'abteieeimiyirerreeinpntsrtstn/eioiaj'oere'os.nsss.noe.'.enO.Oaffp..i-validator.js-f/03_invalid_missing_property.json

Summary

I hope this is helpful for using JSON:API.