Legend:
Library
Module
Module type
Parameter
Class
Class type
To attach additional content to documents, YOCaml uses a Metadata mechanism. Generally, the formats used for this kind of metadata (Yaml, JSON or even TOML) can be abstractly represented as abstract objects, like a key-value table.
This module abstracts the validation logic and the representation for key-value structured data.
Validation
To be able to validate structured data, one must first provide visitors for each data type supported by the metadata description logic.
A visitor takes a structured data structure and if it respects the expected schema, applies a function with the extracted data, otherwise it applies another function. In a slightly less generic way, the function that acts on the extracted data can act as a validation and the one that is applied in case of non respect of the structure is the failure function.
The set of visitors for a key-value structurable object
The representation proposed by the Jsonm library has become so popular that it is the representation used for ocaml-mustache and ocaml-yaml. As the AST is described by means of polymorphic variants, it is possible to provide validators without the need to depend on the library.