@@ -332,6 +332,15 @@ module Validation : sig
332332 (* * [where ?pp predicate x] ensure that [x] is satisfying [predicate]. [pp] is
333333 used for error-reporting.*)
334334
335+ val where_opt :
336+ ?pp : (Format .formatter -> 'a -> unit )
337+ -> ?message : ('a -> string )
338+ -> ('a -> 'b option )
339+ -> 'a
340+ -> 'b validated_value
341+ (* * [where_opt ?pp predicate x] ensure that [predicate x] return [Some]. [pp]
342+ is used for error-reporting.*)
343+
335344 val const : 'a -> 'b -> ('a , 'c ) result
336345 (* * [const k r] wrap [k] as valid and discard [r]. *)
337346
@@ -535,6 +544,14 @@ module Validation : sig
535544 (* * [where ?message predicate actual] ensures that [actual] satisfies
536545 [predicate]. [message] is used for custom error messages. *)
537546
547+ val where_opt :
548+ ?message : (string -> string )
549+ -> (string -> 'b option )
550+ -> string
551+ -> 'b validated_value
552+ (* * [where_opt ?pp predicate x] ensure that [predicate x] return [Some].
553+ [pp] is used for error-reporting.*)
554+
538555 (* * Useful function to be used with regular string validators. *)
539556
540557 val lowercase_ascii : string -> string
@@ -576,6 +593,13 @@ module Validation : sig
576593 val where :
577594 ?message : (int -> string ) -> (int -> bool ) -> int -> int validated_value
578595 (* * Integer version of {!val:Data.Validation.where} *)
596+
597+ val where_opt :
598+ ?message : (int -> string )
599+ -> (int -> 'b option )
600+ -> int
601+ -> 'b validated_value
602+ (* * Integer version of {!val:Data.Validation.where_opt} *)
579603 end
580604
581605 (* * {2 Float validators}
@@ -616,6 +640,13 @@ module Validation : sig
616640 -> float
617641 -> float validated_value
618642 (* * Float version of {!val:Data.Validation.where} *)
643+
644+ val where_opt :
645+ ?message : (float -> string )
646+ -> (float -> 'b option )
647+ -> float
648+ -> 'b validated_value
649+ (* * Integer version of {!val:Data.Validation.where_opt} *)
619650 end
620651
621652 (* * {2 Validator combinators} *)
0 commit comments