> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# DA.Validation

> Reference documentation for Daml module DA.Validation.

Daml module

# DA.Validation

Validation type and associated functions.

Daml

[Updated 3.5.1](#history-updated-3-5-1)

Module
DA.Validation

Latest release
3.7.5

## Data Types

### `data Validation err a`

A `Validation` represents eithor a non-empty list of errors, or a successful value.
This generalizes `Either` to allow more than one error to be collected.

Constructors:

* `Errors (NonEmpty err)`

- `Success a`

Instances:

* instance [`Foldable`](https://docs.canton.network/appdev/reference/daml-standard-library/da-foldable#class-da-foldable-foldable-25994) ([`Validation`](#type-da-validation-types-validation-39644) `err`)
* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) ([`Validation`](#type-da-validation-types-validation-39644) `err`)
* instance [`Semigroup`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-semigroup-78998) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)
* instance [`Traversable`](https://docs.canton.network/appdev/reference/daml-standard-library/da-traversable#class-da-traversable-traversable-18144) ([`Validation`](#type-da-validation-types-validation-39644) `err`)
* instance (`Serializable` `err`, `Serializable` `a`) => `Serializable` ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)
* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`Validation`](#type-da-validation-types-validation-39644) `err`)
* instance ([`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `err`, [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `a`) => [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)
* instance ([`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `err`, [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `a`) => [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)

## Functions

### `invalid`

`invalid` : `err` -> [`Validation`](#type-da-validation-types-validation-39644) `err` `a`

Fail for the given reason.

### `ok`

`ok` : `a` -> [`Validation`](#type-da-validation-types-validation-39644) `err` `a`

Succeed with the given value.

### `validate`

`validate` : [`Either`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-types-either-56020) `err` `a` -> [`Validation`](#type-da-validation-types-validation-39644) `err` `a`

Turn an `Either` into a `Validation`.

### `run`

`run` : [`Validation`](#type-da-validation-types-validation-39644) `err` `a` -> [`Either`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-types-either-56020) ([`NonEmpty`](https://docs.canton.network/appdev/reference/daml-standard-library/da-nonempty-types#type-da-nonempty-types-nonempty-16010) `err`) `a`

Convert a `Validation err a` value into an `Either`,
taking the non-empty list of errors as the left value.

### `run1`

`run1` : [`Validation`](#type-da-validation-types-validation-39644) `err` `a` -> [`Either`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-types-either-56020) `err` `a`

Convert a `Validation err a` value into an `Either`,
taking just the first error as the left value.

### `runWithDefault`

`runWithDefault` : `a` -> [`Validation`](#type-da-validation-types-validation-39644) `err` `a` -> `a`

Run a `Validation err a` with a default value in case of errors.

### `<?>`

`<?>` : [`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) `b` -> `err` -> [`Validation`](#type-da-validation-types-validation-39644) `err` `b`

Convert an `Optional t` into a `Validation err t`, or
more generally into an `m t` for any `ActionFail` type `m`.

## Orphan Typeclass Instances

* instance ([`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `err`, [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `a`) => [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)

* instance ([`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `err`, [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `a`) => [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)

* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`Validation`](#type-da-validation-types-validation-39644) `err`)

* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) ([`Validation`](#type-da-validation-types-validation-39644) `err`)

* instance [`Semigroup`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-semigroup-78998) ([`Validation`](#type-da-validation-types-validation-39644) `err` `a`)

* instance [`Foldable`](https://docs.canton.network/appdev/reference/daml-standard-library/da-foldable#class-da-foldable-foldable-25994) ([`Validation`](#type-da-validation-types-validation-39644) `err`)

* instance [`Traversable`](https://docs.canton.network/appdev/reference/daml-standard-library/da-traversable#class-da-traversable-traversable-18144) ([`Validation`](#type-da-validation-types-validation-39644) `err`)

## History

Updated
`3.5.1`

Module declarations or documentation updated.
