package conformist

  1. Overview
  2. Docs
Module type
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 List.t -> error_msg option

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

val optional : 'a any_field -> bool

optional field returns true if the field is optional and false otherwise.

  • deprecated Please use is_optional instead
val is_optional : 'a any_field -> bool

is_optional field returns true if the field is optional and false otherwise.

val type_ : 'a any_field -> string

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

val encode_default : 'a any_field -> string List.t

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