Combines two validations together such that failures are aggregated.
forall a, b:
(Validation a b).(Validation a b) => Validation a b
where a is Semigroup
Combines two validations together such that failures are aggregated.
In cases where both validations contain a successful value, this method just selects the last validation.
const { Success, Failure } = require('folktale/validation');
Failure('a').concat(Failure('b'));
// ==> Failure('ab')
Failure('a').concat(Success('b'));
// ==> Failure('a')
Success('a').concat(Failure('b'));
// ==> Failure('b')
Success('a').concat(Success('b'));
// ==> Success('b')
{
/*~*/
Failure: function concat(aValidation) {
assertValidation('Validation.Failure#concat', aValidation);
if (Failure.hasInstance(aValidation)) {
return Failure(this.value.concat(aValidation.value));
} else {
return this;
}
},
/*~*/
Success: function concat(aValidation) {
assertValidation('Validation.Success#concat', aValidation);
return aValidation;
}
}