summaryrefslogtreecommitdiff
path: root/lib/model/field.mli
blob: 0619f3306f7741f92a71e3aa2c141138492c7305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
type textI18n = (string * string) list
(** A label is just an association list*)

type validation = { rule : string list Dsl.t; message : textI18n }
type 't field_ex = T : ('db, 'ocaml, 't) Typ.t -> 't field_ex

type 'ref t
(** Description of a field *)

val named_of :
  'ref t -> ('db, 'ocaml, 'ref) Typ.t -> (('db, 'ocaml, 'ref) Typ.t) Typ.named option
(** [named_of field typ] is [Some named] — the field's {!Typ.named} type,
    stamped with ['db] and ['ocaml] — when [typ] matches the declared type of
    [field] (checked with {!Typ.eq} and {!Typ.eq_ocaml}); [None] on type
    mismatch *)

val create :
  'ref field_ex ->
  textI18n ->
  ?placeholder:textI18n ->
  ?icon:unit ->
  ?required:bool ->
  ?validation:validation list ->
  ?criteria:string list Dsl.t ->
  Identifier.t ->
  'ref t

val name : _ t -> Identifier.t
(** Name (identifier) for the field *)

val label : _ t -> textI18n
val placeholder : _ t -> textI18n option
val icon : _ t -> unit option
val type_ : 'ref t -> 'ref field_ex
val required : _ t -> bool
val validation : _ t -> validation list
val criteria : _ t -> string list Dsl.t option