@@ -77,16 +77,16 @@ module Validation=
7777 | Success a -> f a
7878
7979 /// orElse v a returns 'a when v is Failure, and the a in Success a.
80- let orElse v ( a : 'a ) =
81- match v with
82- | Failure _ -> a
83- | Success x -> x
80+ [<System.Obsolete( " Use Validation.defaultValue instead." ) >]
81+ let orElse v ( a : 'a ) = match v with | Failure _ -> a | Success x -> x
82+ /// defaultValue value source returns value when source is Failure, and the v in Success v.
83+ let defaultValue ( value : 'a ) ( source : Validation < 'err , 'a >) : 'a = match source with Success v -> v | _ -> value
84+ /// defaultWith returns either x when the source is Success x, otherwise applies the function f on e if the source is Failure e.
85+ let defaultWith ( f : 'err -> 'a ) ( source : Validation < 'err , 'a >) : 'a = match source with | Success x -> x | Failure e -> f e
8486
8587 /// Return the 'a or run the given function over the 'e.
86- let valueOr ea ( v : Validation < 'e , 'a >) =
87- match v with
88- | Failure e -> ea e
89- | Success a -> a
88+ [<System.Obsolete( " Use Validation.defaultWith instead." ) >]
89+ let valueOr ea ( v : Validation < 'e , 'a >) = match v with | Failure e -> ea e | Success a -> a
9090
9191 /// 'liftResult' is useful for converting a 'Result' to an 'Validation'
9292 /// when the 'Error' of the 'Result' needs to be lifted into a 'Semigroup'.
@@ -113,6 +113,7 @@ module Validation=
113113 ///
114114 /// validate : 'e -> ('a -> bool) -> 'a -> Validation<'e, 'a>
115115 ///
116+ [<System.Obsolete( " This function will not be supported in future versions." ) >]
116117 let validate ( e : 'e ) ( p : 'a -> bool ) ( a : 'a ) : Validation < 'e , 'a > = if p a then Success a else Failure e
117118
118119 #if ! FABLE_ COMPILER
@@ -128,6 +129,7 @@ module Validation=
128129 /// This can be thought of as having the less general type:
129130 ///
130131 /// ensure : 'e -> ('a -> 'bool) -> Validation<'a,'e> -> Validation<'a,'e>
132+ [<System.Obsolete( " This function will not be supported in future versions." ) >]
131133 let ensure ( e : 'e ) ( p : 'a -> bool ) = function
132134 | Failure x -> Failure x
133135 | Success a -> validate e p a
0 commit comments