A convenience method for the folktale/conversions/nullable-to-validation
module.
forall a, b: (a or None, b) => Validation b a
A convenience method for the folktale/conversions/nullable-to-validation
module.
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')
fromNullable(aNullable, fallbackValue) {
return require('folktale/conversions/nullable-to-validation')(aNullable, fallbackValue);
}