fromNullable

A convenience method for the folktale/conversions/nullable-to-validation module.

Signature

fromNullable(aNullable, fallbackValue)
forall a, b: (a or None, b) => Validation b a

Documentation

A convenience method for the folktale/conversions/nullable-to-validation module.

Example:

const Validation = require('folktale/validation');

Validation.fromNullable(1, 'error');
// ==> Validation.Success(1)

Validation.fromNullable(null, 'error');
// ==> Validation.Failure('error')

Validation.fromNullable(undefined, 'error');
// ==> Validation.Failure('error')

Properties

Source Code

Defined in source/validation/index.js at line 18, column 17
fromNullable(aNullable, fallbackValue) {
    return require('folktale/conversions/nullable-to-validation')(aNullable, fallbackValue);
  }
Licence
MIT
Module
folktale/validation
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)