map

Transforms the successful value inside a Validation structure with an unary function without changing the status of the validation. That is, Success values continue to be Success values, Failure values continue to be Failure values.

Signature

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

Documentation

Transforms the successful value inside a Validation structure with an unary function without changing the status of the validation. That is, Success values continue to be Success values, Failure values continue to be Failure values.

Example:

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

const upcase = (a) => a.toUpperCase();

Success('a').map(upcase);
// ==> Success('A')

Failure('a').map(upcase);
// ==> Failure('a')

Properties

Source Code

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

    /*~*/
    Success: function map(transformation) {
      assertFunction('Validation.Success#map', transformation);
      return Success(transformation(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/)