concat

Combines two validations together such that failures are aggregated.

Signature

forall a, b:
  (Validation a b).(Validation a b) => Validation a b
where a is Semigroup

Documentation

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.

Example:

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')

Properties

Source Code

Defined in source/validation/validation.js at line 70, column 23
{
    /*~*/
    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;
    }
  }
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/)