Success

Constructs a Validation whose value represents a success.

This feature is experimental!

This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.

Signature

Success(value)
forall a, b: (b) => Validation a b

Documentation

Constructs a Validation whose value represents a success.

See the documentation for the Validation structure to understand how to use this.

Static properties

Comparing and testing

hasInstance(value)

Tests if an arbitrary value is a Success case of a Validation instance.

Experimental

Debugging

inspect: toString()

A textual representation of the Success variant.

Experimental
toString()

A textual representation of the Success variant.

Experimental

Special values

get constructor

The constructor for this variant.

Experimental
prototype

The container for instance methods for Success variants of the Validation structure.

Experimental
get tag

The tag for this variant, unique among the Validation variants.

Experimental
get type

The type for this variant, unique among Folktale data structures (and ideally unique among all unions in your application, as its used for type checking).

Experimental

Instance (prototype) properties

Combining validations

apply()

If successes, applies the function in one Validation to another. Otherwise concatenate the failures.

concat()

Combines two validations together such that failures are aggregated.

Comparing and testing

equals(value)

Performs a deep-comparison of two Validation values for equality.

Experimental
hasInstance(value)

Tests if an arbitrary value is a Validation instance.

ExperimentalInherited
get isSuccess

True if the value is a Success instance.

Deprecated

Constructing

of(value)

Constructs a Validation holding a Success value.

Inherited

Converting to other types

toMaybe()

Transforms a Validation into a Maybe. Failure values are lost in the process.

Inherited
toResult()

Transforms a Validation into a Reseult.

Inherited

Data fields

get value

The value contained in an Success instance of the Validation structure.

Abstract

Debugging

inspect: toString()

A textual representation for Validation instances.

Experimental
toString()

A textual representation for Validation instances.

Experimental

Extracting values

get()

This method has been renamed to unsafeGet().

DeprecatedInherited
getOrElse()

Extracts the value of a Validation structure, if it's a Success, otherwise returns the provided default value.

merge()

Returns the value inside of the Validation structure, regardless of its state.

Inherited
unsafeGet()

Extracts the value from a Validation structure.

Fantasy Land

ap(that)

Part of the Applicative instance for Fantasy Land 1.x. See the apply method for details.

fantasy-land/ap(that)

Part of the Applicative instance for Fantasy Land 2.x+. See the apply method for details.

fantasy-land/bimap(f, g)

Part of the Bifunctor instance for Fantasy Land 2.x+. See the bimap method for details.

fantasy-land/concat(that)

Part of the Semigroup instance for Fantasy Land 2.x+. See the concat method for details.

fantasy-land/equals(that)

Part of the Setoid instance for Fantasy Land 2.x+. See the equals method for details.

fantasy-land/map(transformation)

Part of the Functor instance for Fantasy Land 2.x+. See the map method for details.

fantasy-land/of(value)

Part of the Applicative instance for Fantasy Land 2.x+. See the of method for details.

Meta-programming

derive(...derivations)

Allows a function to provide functionality to variants in an union.

ExperimentalInherited

Pattern matching

fold()

Applies a function to each case of a Validation.

matchWith(pattern)

Chooses and executes a function for each variant in the Validation structure.

Experimental

Recovering from errors

orElse()

Allows recovering from Failure values with a handler function.

swap()

Inverts the status of a Validation, such that Failures become Successes, and vice-versa.

Serialising

fromJSON(value, parsers = { [typeName]: adt }, keysIndicateType = false)

Parses a JavaScript object previously serialised as aValidation.toJSON() into a proper Validation structure.

ExperimentalInherited
toJSON()

Converts a Validation value to a JavaScript object that may be stored as a JSON value.

Experimental

Special values

get constructor

The constructor for this variant.

variants

The variants in the Validation structure.

ExperimentalInherited

Transforming

bimap()

Transforms each side of a Validation with a function, without changing the status of the validation. That is, failures will still be failures, successes will still be successes.

map()

Transforms the successful 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.

mapFailure()

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.

Variants

Failure(value)

Constructs a Validation whose value represents a failure.

ExperimentalInherited
Success(value)

Constructs a Validation whose value represents a success.

ExperimentalInherited

Source Code

Success(value) { 
    return { value };
  }
Stability
experimental
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/)