Transforms the failure 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.
forall a, b, c:
(Validation a b).((a) => c) Validation c b
Transforms the failure 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.
const { Success, Failure } = require('folktale/validation');
const upcase = (a) => a.toUpperCase();
Success('a').mapFailure(upcase);
// ==> Success('a')
Failure('a').mapFailure(upcase);
// ==> Failure('A')
{
/*~*/
Failure: function mapFailure(transformation) {
assertFunction('Validation.Failure#mapFailure', transformation);
return Failure(transformation(this.value));
},
/*~*/
Success: function mapFailure(transformation) {
assertFunction('Validation.Failure#mapFailure', transformation);
return this;
}
}