File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,6 +186,18 @@ module Validation =
186186 /// Creates a Validation<'Error,'T> from a Choice<'T,'Error>.
187187 let ofChoice ( x : Choice < 'T , 'Error >) = match x with Choice1Of2 a -> Success a | Choice2Of2 e -> Failure e
188188
189+ /// <summary >Converts an option to a Validation.</summary >
190+ /// <param name =" errorValue " >The error value to be used in case of None.</param >
191+ /// <param name =" source " >The option value.</param >
192+ /// <returns >The resulting Validation value.</returns >
193+ let ofOptionWith ( errorValue : 'Error ) ( source : 'T option ) = match source with Some x -> Success x | None -> Failure errorValue
194+
195+ /// <summary >Converts a voption to a Validation.</summary >
196+ /// <param name =" errorValue " >The error value to be used in case of None.</param >
197+ /// <param name =" source " >The voption value.</param >
198+ /// <returns >The resulting Validation value.</returns >
199+ let ofValueOptionWith ( errorValue : 'Error ) ( source : 'T voption ) = match source with ValueSome x -> Success x | ValueNone -> Failure errorValue
200+
189201 /// <summary > Extracts a value from either side of a Validation.</summary >
190202 /// <param name =" successMapper " >Function to be applied to source, if it contains a Success value.</param >
191203 /// <param name =" failureMapper " >Function to be applied to source, if it contains a Failure value.</param >
You can’t perform that action at this time.
0 commit comments