getOrElse

Extracts the value of a Validation structure, if it's a Success, otherwise returns the provided default value.

Signature

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

Documentation

Extracts the value of a Validation structure, if it's a Success, otherwise returns the provided default value.

Example:

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

Success('a').getOrElse('b');
// ==> 'a'

Failure('a').getOrElse('b');
// ==> 'b'

Properties

Source Code

Defined in source/validation/validation.js at line 70, column 23
{
    /*~*/
    Failure: function getOrElse(_default) {
      return _default;
    },

    /*~*/
    Success: function getOrElse(_default) {
      return this.value;
    }
  }
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/)