package yocaml

  1. Overview
  2. Docs

Module Yocaml.MetadataSource

Metadata validation

Data validation tools.

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

A type that describes validated metadata.

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

Helper for Yocaml.Required.DATA_READABLE.neutral.

Sourceval 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.

Sourcetype 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.

Sourceval regular : char -> extraction_strategy

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

Define the front-matter delimiter.

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

Define a custom extraction strategy.

Extraction

Sourceval 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.