You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking for an OCaml library to validate Yojson objects against a JSON schema and this library looks like the only one remotely related to that task. Unfortunately, I cannot figure out how to do it and am not suspecting it's not actually provided as a feature.
Json_schema does allow parsing JSON schemas from JSON objects themselves. Json_encoding implements all the validation rules, but that's on statically typed encodings, not arbitrary runtime schemas, which is what I want.
But there doesn't seem to be a way to convert a Json_schema.schema to any kind of Json_encoding.encoding, which would actually validate objects against the schema when destructing. There's custom, but that just stores the schema without checking.
Am I missing something or is it impossible to use this library for arbitrary schema validation?
The text was updated successfully, but these errors were encountered:
This repo is not maintained anymore, the successor is json-data-encoding.
Regarding validation of schema, it is not handled unfortunately, there is a nice commentary (* TODO: validator *) in the file json_schema.ml, but I don't think anybody is working on it.
This repo is not maintained anymore, the successor is json-data-encoding. Regarding validation of schema, it is not handled unfortunately, there is a nice commentary (* TODO: validator *) in the file json_schema.ml, but I don't think anybody is working on it.
Thanks for pointing that out! This repo looked inactive indeed, but it wasn't obvious that there's a successor somewhere.
Seems like I might be able to define a function Json_schema.schema -> unit Json_encoding.encoding (for at least the basic constructs I'm interested in) to have a type- and value-erased encoding, which on destruct at least checks the representation and signals invalidity through Cannot_destruct. Kind of hacky, but hopefully less work than writing everything from scratch for the time being.
I was looking for an OCaml library to validate Yojson objects against a JSON schema and this library looks like the only one remotely related to that task. Unfortunately, I cannot figure out how to do it and am not suspecting it's not actually provided as a feature.
Json_schema
does allow parsing JSON schemas from JSON objects themselves.Json_encoding
implements all the validation rules, but that's on statically typed encodings, not arbitrary runtime schemas, which is what I want.But there doesn't seem to be a way to convert a
Json_schema.schema
to any kind ofJson_encoding.encoding
, which would actually validate objects against the schema when destructing. There'scustom
, but that just stores the schema without checking.Am I missing something or is it impossible to use this library for arbitrary schema validation?
The text was updated successfully, but these errors were encountered: