package yocaml

  1. Overview
  2. Docs

Metadata validation

Data validation tools.

type 'a validated = ('a, Required.provider_error) result

A type that describes validated metadata.

val required : string -> ('a, Required.provider_error) result

Helper for Yocaml.Required.DATA_READABLE.neutral.

val validate : (module Required.DATA_PROVIDER) -> (module Required.DATA_READABLE with type t = 'a) -> string option -> 'a validated

validate (module Provider) (module Readable) opt_str Validates an optional string described in the syntax described by the Provider module using the validation function described by the Readable module. The function uses Readable.neutral as a fallback if the string is null.

Metadata extraction

A set of functions for extracting metadata from a read document.

Extraction strategy

Defines the extraction strategy for a set of metadata.

type extraction_strategy =
  1. | Regular of char
  2. | Custom of string -> string option * string

There are several strategies for describing how to separate metadata from the actual content, but it is also possible to provide your own implementation using the Custom constructor.

val regular : char -> extraction_strategy

Define a regular strategy, using 3 char as a delimiter.

val jekyll : extraction_strategy

Define the front-matter delimiter.

val custom : (string -> string option * string) -> extraction_strategy

Define a custom extraction strategy.

Extraction

val extract_from_content : strategy:extraction_strategy -> string -> string option * string

extract_from_content ~strategy content Attempts to extract metadata from a document using a defined strategy.

OCaml

Innovation. Community. Security.