orElse

Allows recovering from Failure values with a handler function.

Signature

forall a, b, c:
  (Validation a b).((a) => Validation c b) => Validation c b

Documentation

Allows recovering from Failure values with a handler function.

Example:

const { Success, Failure } = require('folktale/validation');

Success('a').orElse(e => Success('b'));
// ==> Success('a')

Failure('a').orElse(e => Success('b'));
// ==> Success('b')

Failure('a').orElse(e => Failure('b'));
// ==> Failure('b')

Properties

Source Code

Defined in source/validation/validation.js at line 70, column 23
{
    /*~*/
    Failure: function orElse(handler) {
      assertFunction('Validation.Failure#orElse', handler);
      return handler(this.value);
    },

    /*~*/
    Success: function orElse(handler) {
      assertFunction('Validation.Success#orElse', handler);
      return this;
    }
  }
Licence
MIT
Module
folktale/validation/validation
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)