Module Form.Data

Form data.

type form = t
type entry_value = [
  1. | `String of Jstr.t
  2. | `File of Brr.File.t

The type for form data entry values.

type t

The type for FormData objects.

val create : unit -> t

create () is new, empty, form data.

val of_form : form -> t

of_form f is a form data from the current key-values of form f.

val is_empty : t -> bool

is_empty d is true if d has no entries.

val has_file_entry : t -> bool

has_file_entry d is true iff d has a file entry.

val mem : t -> Jstr.t -> bool

mem d k is true if d has key k.

val find : t -> Jstr.t -> entry_value option

find d k is the first value associated to k in d (if any).

val find_all : t -> Jstr.t -> entry_value list

find_all d k are all the values associated to k in d.

val fold : (Jstr.t -> entry_value -> 'a -> 'a) -> t -> 'a -> 'a

fold f d acc folds over all key/value entries in d with f starting with k.

val set : t -> Jstr.t -> Jstr.t -> unit

set d k v sets the value of k to v in d.

val set_blob : ?filename:Jstr.t -> t -> Jstr.t -> Brr.Blob.t -> unit

set d k b ~filename sets the value of k to b in d. filename can specify the filename of b.

val append : t -> Jstr.t -> Jstr.t -> unit

append d k v appends value v to the value of k in d.

val append_blob : ?filename:Jstr.t -> t -> Jstr.t -> Brr.Blob.t -> unit

append d k b ~filename appends blob b to the value of k in d. filename can specify the filename of b.

val delete : t -> Jstr.t -> unit

delete d k deletes the values of key k in d.


val of_assoc : (Jstr.t * entry_value) list -> t

of_assoc l is form data from assoc l, data is appended.

val to_assoc : t -> (Jstr.t * entry_value) list

to_assoc l is the form data as an association list.

val of_uri_params : Brr.Uri.Params.t -> t

of_uri_params p is a form data for p.

val to_uri_params : t -> Brr.Uri.Params.t

to_uri_params t is the form data as URI query parameters.

Note. If your form has file inputs this will map their keys to something like "[Object File]", has_file_entry indicates whether the form data has a file entry.