resultToValidation

Converts an Result to a Validation. Errors map to Failures, Oks map to Successes.

Signature

resultToValidation(aResult)
forall a, b:
  (Result a b) => Validation a b

Documentation

Converts an Result to a Validation. Errors map to Failures, Oks map to Successes.

Example:

const resultToValidation = require('folktale/conversions/result-to-validation');
const { Error, Ok } = require('folktale/result');
const { Failure, Success } = require('folktale/validation');

resultToValidation(Error(1));  // ==> Failure(1)
resultToValidation(Ok(1)); // ==> Success(1)

Properties

Source Code

Defined in source/conversions/result-to-validation.js at line 22, column 0
(aResult) =>
  aResult.matchWith({
    Error: ({ value }) => Failure(value),
    Ok: ({ value }) => Success(value)
  })
Stability
stable
Licence
MIT
Module
folktale/conversions/result-to-validation
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • @boris-marinov
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)