12345678910111213141516171819202122232425262728293031323334353637383940414243444546(*
Mapping from ATD to "validate"
*)openPrintftypevalidate_repr=(stringoption*bool)(* (opt_v, b)
is obtained by analyzing all available type definitions.
The first value opt_v is the optional local validator
coming from an ATD annotation (see `Local).
The second value b is true iff the data doesn't need scanning.
There are four cases:
opt_v = None && b = true => no validation is needed at all
opt_v = None && b = false => validators must be called on some
sub-fields of the data
opt_v <> None && b = true => the given validator must be called
but there's no need to look into
the sub-fields
opt_v <> None && b = false => the given validator must be called
in addition to scanning sub-fields
*)letmake_full_validators=sprintf"\
fun path x -> \
if ( %s ) x then None \
else Some (Ag_util.Validation.error path)"sletget_validatoran=letfull=Atd_annot.get_field(funs->Some(Somes))None["ocaml"]"validator"aninmatchfullwith|Some_->full|None->letshorthand=Atd_annot.get_field(funs->Some(Somes))None["ocaml"]"valid"aninmatchshorthandwith|None->None|Somes->Some(make_full_validators)