validationToResult

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

Signature

validationToResult(aValidation)
forall a, b:
   (Validation a b) => Result a b

Documentation

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

Example:

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) 

Properties

Source Code

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