package awsm

  1. Overview
  2. Docs

Extension of Core library.

module String : sig ... end
module Test : sig ... end

Utility functions for writing tests.

val check_string_min : string -> min:int -> (unit, string) Core.Result.t

check_string_min s m returns Ok () if s is at least of size m, or an error otherwise.

val check_string_max : string -> max:int -> (unit, string) Core.Result.t

check_string_max s m returns Ok () if s is at most of size m, or an error otherwise.

val check_pattern : string -> pattern:string -> (unit, string) Core.Result.t

check_pattern s p returns Ok () if s matches with pattern p, or an error otherwise.

val check_list_min : 'a list -> min:int -> (unit, string) Core.Result.t

check_list_min l m returns Ok () if l is at least of size m, or an error otherwise.

val check_list_max : 'a list -> max:int -> (unit, string) Core.Result.t

check_list_max l m returns Ok () if l is at most of size m, or an error otherwise.

val check_int_min : int -> min:int -> (unit, string) Core.Result.t

check_int_min i m returns Ok () if i is at least equal to m, or an error otherwise.

val check_int_max : int -> max:int -> (unit, string) Core.Result.t

check_int_max i m returns Ok () if i is at most equal to m, or an error otherwise.

val check_int64_min : int64 -> min:int64 -> (unit, string) Core.Result.t

check_int64_min i m f returns Ok () if i is at least equal to m, or an error otherwise.

val check_int64_max : int64 -> max:int64 -> (unit, string) Core.Result.t

check_int64_min i m f returns Ok () if i is at most equal to m, or an error otherwise.

val check_float_min : float -> min:float -> (unit, string) Core.Result.t

check_float_min i m returns Ok () if i is at least equal to m, or an error otherwise.

val check_float_max : float -> max:float -> (unit, string) Core.Result.t

check_float_max i m returns Ok () if i is at most equal to m, or an error otherwise.

val string_of_xml : kind:string -> 'a Xmlm.frag as 'a Xmlm.frag -> string

string_of_xml ~kind node checks if node represents a string, and returns it. Otherwise, it returns an error (mentioning the kind of value being parsed).

val bool_of_json : Json.t -> bool

Convert a JSON value to a boolean (or fail with an exception).

val float_of_json : kind:string -> Json.t -> float

Convert a JSON value to a float (or fail with an exception mentioning the kind of value being parsed).

val string_of_json : kind:string -> Json.t -> string

Convert a JSON value to a string (or fail with an exception mentioning the kind of value being parsed).

val timestamp_of_json : Json.t -> string

Convert a JSON value to a timestamp (or fail with an exception).

val list_of_json : kind:string -> of_json:(Json.t -> 'a) -> [> Json.t ] -> 'a list

Convert a JSON value to a list (or fail with an exception mentioning the kind of value being parsed).

val object_of_json : key_of_string:(string -> 'key) -> of_json:(Json.t -> 'value) -> Json.t -> ('key * 'value) list

Convert a JSON object to an association list (or fail with an exception).

OCaml

Innovation. Community. Security.