package conformist

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type ('meta, 'a) t

A field of type ('meta, 'a) t represents the static type 'a and it can hold arbitrary meta data of type 'meta. That meta data can be used to build functionality on top of conformist.

type (_, _, _) list =
  1. | [] : ('meta, 'ty, 'ty) list
  2. | :: : ('meta, 'a) t * ('meta, 'b, 'ty) list -> ('meta, 'a -> 'b, 'ty) list
    (*

    A list is a list of fields. Note that this is not the list from List.t so make sure to open this scope locally when defining a list of fields.

    *)
type _ any_field =
  1. | AnyField : ('meta, 'a) t -> 'meta any_field
val meta : 'a any_field -> 'a option

meta field returns an optional meta data of a field. This can be used to store arbitrary meta data in each field. Note that the type of the meta data has to be the same for all fields.

val name : 'a any_field -> string

name field returns the name of the field, which uniquely identifies the field within one schema.

val validate : 'a any_field -> string -> string option

validate field string decodes a string and runs the field's validation logic on the decoded value. Both decoding and validation might fail, which results in an error string.

val optional : 'a any_field -> bool

optional field turns a field into an optional field. This means that input that doesn't contain a value for the field will yield in a valid field.

val type_ : 'a any_field -> string

type_ field returns a string representation of the type of field.

val encode_default : 'a any_field -> string option

encode_default field tries to encode the default value if present and to return it as string.