Converts a Validation
to an Result
. Failure
s map to Error
s,
Success
es map to Ok
s.
forall a, b:
(Validation a b) => Result a b
Converts a Validation
to an Result
. Failure
s map to Error
s,
Success
es map to Ok
s.
const validationToResult = require('folktale/conversions/validation-to-result');
const { Error, Ok } = require('folktale/result');
const { Failure, Success } = require('folktale/validation');
validationToResult(Failure(1)); // ==> Error(1)
validationToResult(Success(1)); // ==> Ok(1)
(aValidation) =>
aValidation.matchWith({
Failure: ({ value }) => Error(value),
Success: ({ value }) => Ok(value)
})