package conformist

  1. Overview
  2. Docs

Module Conformist.FieldSource

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

Sourcetype (_, _, _) 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.

    *)
Sourcetype _ any_field =
  1. | AnyField : ('meta, 'a) t -> 'meta any_field
Sourceval 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.

Sourceval name : 'a any_field -> string

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

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

Sourceval optional : 'a any_field -> bool

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

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

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

Sourceval type_ : 'a any_field -> string

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

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

OCaml

Innovation. Community. Security.