The result of a validation. This effectively contains the list of errors, qualified by their location path
type 'a check = 'a -> tTo make function signatures easier to read.
val pass : tA result containing no errors.
val fail : string -> tA result containing a single error.
val failf : ('a, unit, string, t) Stdlib.format4 -> 'aLike sprintf or failwithf but produces a t instead of a string or exception.
val fail_fn : string -> _ checkfail_fn err returns a function that always returns fail, with err as the error message. (Note that there is no pass_fn so as to discourage people from ignoring the type of the value being passed unconditionally irrespective of type.)
val pass_bool : bool checkChecks for unconditionally passing a bool.
val pass_unit : unit checkChecks for unconditionally passing a unit.
protect f x applies the validation f to x, catching any exceptions and returning them as errors.
val try_with : (unit -> unit) -> ttry_with f runs f catching any exceptions and returning them as errors.
val result : t -> unit Or_error.tval errors : t -> string listReturns a list of formatted error strings, which include both the error message and the path to the error.
val maybe_raise : t -> unitIf the result contains any errors, then raises an exception with a formatted error message containing a message for every error.
val valid_or_error : 'a -> 'a check -> 'a Or_error.tReturns an error if validation fails.
val field : 'record -> ([> `Read ], 'record, 'a) Field.t_with_perm -> 'a check -> tUsed for validating an individual field.
val field_folder : 'record -> 'a check -> t list -> ([> `Read ], 'record, 'a) Field.t_with_perm -> t listCreates a function for use in a Fields.fold.
val field_direct_folder : 'a check -> (t list -> ([> `Read ], 'record, 'a) Field.t_with_perm -> 'record -> 'a -> t list) Staged.tCreates a function for use in a Fields.Direct.fold.
Combines a list of validation functions into one that does all validations.
Creates a validation function from a function that produces a Result.t.
val of_error : ('a -> unit Or_error.t) -> 'a checkval booltest : ('a -> bool) -> if_false:string -> 'a checkCreates a validation function from a function that produces a bool.
Validation functions for particular data types.
Validates a list, naming each element by its position in the list (where the first position is 1, not 0).
Validates a list, naming each element using a user-defined function for computing the name.
val of_error_opt : string option -> tValidates an association list, naming each element using a user-defined function for computing the name.
val bounded : name:('a -> string) -> lower:'a Maybe_bound.t -> upper:'a Maybe_bound.t -> compare:('a -> 'a -> int) -> 'a checkmodule Infix : sig ... end