Formless.Validation
- Package
- purescript-formless-aj
- Repository
- ajnsit/purescript-formless-independent
#Validation Source
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
Validation (form Record FormField -> input -> m (Either error output))
Instances
Newtype (Validation form m e i o) _
(Functor m) => Functor (Validation form m e i)
(Monad m) => Apply (Validation form m e i)
(Monad m) => Applicative (Validation form m e i)
(Monad m) => Alt (Validation form m e i)
(Semigroup (m (Either e o))) => Semigroup (Validation form m e i o)
(Applicative m, Monoid (m (Either e o)), Semigroup (m (Either e o))) => Monoid (Validation form m e i o)
(Monad m) => Semigroupoid (Validation form m e)
(Monad m) => Category (Validation form m e)
(Monad m) => Mapping EmptyValidators a (Validation form m e i i)
#runValidation Source
runValidation :: forall o i e m form. 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
#noValidation Source
noValidation :: forall xs vs m fields form. 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.
#hoistFn Source
hoistFn :: forall o i e m form. 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_ Source
hoistFn_ :: forall o i e m form. Monad m => (i -> o) -> Validation form m e i o
Turn a function from (i -> o) into a proper Validation
#hoistFnE_ Source
hoistFnE_ :: forall o i e m form. 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_ Source
hoistFnME_ :: forall o i e m form. 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
#EmptyValidators Source
data EmptyValidators
The data type used for the noValidation function's heterogenous instance
Constructors
Instances
(Monad m) => Mapping EmptyValidators a (Validation form m e i i)
The heterogeneous instance the noValidation function
#Validations Source
type Validations form m = form Record (Validation form m)
A type synonym that represents a set of form validations that run in a particular monad.
The heterogeneous instance the noValidation function