Module

Formless.Validation

#Validation

newtype Validation form m error input output

A wrapper to represent the validation function on a form field, which can itself take the form state as its first argument. Inspired in some parts by the Validation type from purescript-polyform by @paluh.

Constructors

Instances

#runValidation

runValidation :: forall form m e i o. Monad m => Validation form m e i o -> form Record FormField -> i -> m (Either e o)

A more verbose but clearer function for running a validation function on its inputs

#hoistFn

hoistFn :: forall form m e i o. Monad m => (form Record FormField -> i -> o) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> o) into a proper Validation

#hoistFn_

hoistFn_ :: forall form m e i o. Monad m => (i -> o) -> Validation form m e i o

Turn a function from (i -> o) into a proper Validation

#hoistFnE

hoistFnE :: forall form m e i o. Monad m => (form Record FormField -> i -> Either e o) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> Either e o) into a proper Validation

#hoistFnE_

hoistFnE_ :: forall form m e i o. Monad m => (i -> Either e o) -> Validation form m e i o

Turn a function from (i -> Either e o) into a proper Validation

#hoistFnME

hoistFnME :: forall form m e i o. Monad m => (form Record FormField -> i -> m (Either e o)) -> Validation form m e i o

Turn a function from (form Record FormField -> i -> m (Either e o)) into a proper Validation

#hoistFnME_

hoistFnME_ :: forall form m e i o. Monad m => (i -> m (Either e o)) -> Validation form m e i o

Turn a function from (i -> m (Either e o)) into a proper Validation

#noValidators

noValidators :: forall form fields m vs xs. Monad m => RowToList fields xs => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Record InputField) (Record fields) => MapRecordWithIndex xs (ConstMapping EmptyValidators) fields vs => form Record InputField -> form Record (Validation form m)

A function to create a record of validators that simply pass through all inputs for when no validation is needed. Provide this as your validators function.

#noValidation

noValidation :: forall form m e i. Monad m => Validation form m e i i

A validation function which simply passes through its input value as its output value. Use on individual fields which do not need any validation.

#EmptyValidators

data EmptyValidators

The data type used for the noValidation function's heterogenous instance

Constructors

Instances

Modules