Module

Data.Form.Decoder

Package
purescript-form-decoderDEPRECATED
Repository
amderbar/purescript-form-decoder

#Decoder Source

newtype Decoder err input output

Core type representing a decoder. It decodes input into type input, raising error of type err.

Constructors

Instances

#Validator Source

type Validator err input = Decoder err input Unit

An alias for special decoder that does not produce any outputs. It is used for just validating inputs.

#run Source

run :: forall o i e. Decoder e i o -> i -> V e o

Basic function that decodes input by given decoder.

#identity Source

identity :: forall i e. Semigroup e => Decoder e i i

Primitive decoder that always succeeds with input as it is.

#always Source

always :: forall o i e. Semigroup e => o -> Decoder e i o

Primitive decoder that always succeeds with constant value.

#fail Source

fail :: forall o i e. e -> Decoder e i o

Primitive decoder which always results to invalid.

#int Source

int :: forall e. e -> Decoder e String Int

Decoder into Int, raising err when a input is invalid for an integer.

#number Source

number :: forall e. e -> Decoder e String Number

Decoder into Number, raising err when a input is invalid for a number.

#symbol Source

symbol :: forall s e. Semigroup e => e -> s -> String -> Decoder e String s

Decoder into given data type, raising err when a input is invalid for the data.

#validator Source

validator :: forall i e. Semigroup e => e -> (i -> Boolean) -> Validator e i

Constructor for Validator e i takes a custom validation function.

#required Source

required :: forall e. Semigroup e => e -> Validator e String

Primitive validator limiting by not null.

#minBound Source

minBound :: forall ord e. Semigroup e => Ord ord => e -> ord -> Validator e ord

Primitive validator limiting by minimum bound.

#maxBound Source

maxBound :: forall ord e. Semigroup e => Ord ord => e -> ord -> Validator e ord

Primitive validator limiting by maximum bound.

#minLength Source

minLength :: forall e. Semigroup e => e -> Int -> Validator e String

Primitive validator limiting by minimum length.

#maxLength Source

maxLength :: forall e. Semigroup e => e -> Int -> Validator e String

Primitive validator limiting by maximum length.

#assert Source

assert :: forall o i e. Semigroup e => Validator e i -> Decoder e i o -> Decoder e i o

Apply validator on given decoder. If a input is invalid for given validator, decoding fails.

#when Source

when :: forall i e. Semigroup e => (i -> Boolean) -> Validator e i -> Validator e i

Only checks validity if a condition is true.

#unless Source

unless :: forall i e. Semigroup e => (i -> Boolean) -> Validator e i -> Validator e i

Only checks validity unless a condition is true.

#hoist Source

hoist :: forall o e j i. (j -> i) -> Decoder e i o -> Decoder e j o

hoist is mainly used for accessing sub model of target value.