Formless.Internal.Transform
- Package
- purescript-formless-aj
- Repository
- ajnsit/purescript-formless-independent
#fromScratch Source
fromScratch :: forall r. FromScratch r -> Record r
Apply a builder that produces an output record from an empty record
#FromScratch Source
type FromScratch r = Builder (Record ()) (Record r)
Represents building some output record from an empty record
#allTouched Source
allTouched :: forall fxs fs form. RowToList fs fxs => AllTouched fxs fs => Newtype (form Record FormField) (Record fs) => form Record FormField -> Boolean
A helper function that will count all errors in a record
#countErrors Source
countErrors :: forall fxs fs form. RowToList fs fxs => CountErrors fxs fs => Newtype (form Record FormField) (Record fs) => form Record FormField -> Int
A helper function that will count all errors in a record
#formFieldsToInputFields Source
formFieldsToInputFields :: forall is fs form fxs. RowToList fs fxs => FormFieldsToInputFields fxs fs is => Newtype (form Record InputField) (Record is) => Newtype (form Record FormField) (Record fs) => form Record FormField -> form Record InputField
A helper function that will automatically transform a record of FormField(s) into just the input value
#inputFieldsToFormFields Source
inputFieldsToFormFields :: forall fs is form ixs. RowToList is ixs => InputFieldsToFormFields ixs is fs => Newtype (form Record InputField) (Record is) => Newtype (form Record FormField) (Record fs) => form Record InputField -> form Record FormField
A helper function that will automatically transform a record of FormSpec(s) into a record of FormField(s).
#formFieldsToMaybeOutputFields Source
formFieldsToMaybeOutputFields :: forall os fs form fxs. RowToList fs fxs => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => FormFieldToMaybeOutput fxs fs os => form Record FormField -> Maybe (form Record OutputField)
An intermediate function that transforms a record of FormField into a record
#replaceFormFieldInputs Source
replaceFormFieldInputs :: forall is fs form fxs. RowToList fs fxs => ReplaceFormFieldInputs is fxs fs fs => Newtype (form Record InputField) (Record is) => Newtype (form Record FormField) (Record fs) => form Record InputField -> form Record FormField -> form Record FormField
#validateAll Source
validateAll :: forall m fs form fxs vs. RowToList fs fxs => Monad m => ValidateAll vs fxs fs fs m => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Record FormField) (Record fs) => form Record (Validation form m) -> form Record FormField -> m (form Record FormField)
#unsafeModifyInputVariant Source
unsafeModifyInputVariant :: forall y x form. Newtype (form Variant InputFunction) (Variant x) => Newtype (form Record FormField) (Record y) => (forall o e. FormFieldResult e o -> FormFieldResult e o) -> form Variant InputFunction -> form Record FormField -> form Record FormField
Given a variant of InputFunction and a record with the same labels but FormField values, replace the input of the form field. In addition, modify the form field result to represent whether async validation is going to occur.
#unsafeRunValidationVariant Source
unsafeRunValidationVariant :: forall m z y x form. Monad m => Newtype (form Variant U) (Variant x) => Newtype (form Record FormField) (Record y) => Newtype (form Record (Validation form m)) (Record z) => form Variant U -> form Record (Validation form m) -> form Record FormField -> m (form Record FormField)
#SetFormFieldsTouched Source
class SetFormFieldsTouched (xs :: RowList) (row :: Row Type) (to :: Row Type) | xs -> to where
The class that provides the Builder implementation to set all form fields touched
Members
setFormFieldsTouchedBuilder :: RLProxy xs -> Record row -> FromScratch to
Instances
SetFormFieldsTouched Nil row ()
(IsSymbol name, Cons name (FormField e i o) t0 row, SetFormFieldsTouched tail row from, Row1Cons name (FormField e i o) from to) => SetFormFieldsTouched (Cons name (FormField e i o) tail) row to
#FormFieldsToInputFields Source
class FormFieldsToInputFields (xs :: RowList) (row :: Row Type) (to :: Row Type) | xs -> to where
The class that provides the Builder implementation to efficiently transform the record of FormField to record of InputField.
Members
formFieldsToInputFieldsBuilder :: RLProxy xs -> Record row -> FromScratch to
Instances
FormFieldsToInputFields Nil row ()
(IsSymbol name, Cons name (FormField e i o) trash row, FormFieldsToInputFields tail row from, Row1Cons name (InputField e i o) from to) => FormFieldsToInputFields (Cons name (FormField e i o) tail) row to
#InputFieldsToFormFields Source
class InputFieldsToFormFields (xs :: RowList) (row :: Row Type) (to :: Row Type) | xs -> to where
The class that provides the Builder implementation to efficiently transform the record of InputField to record of FormField.
Members
inputFieldsToFormFieldsBuilder :: RLProxy xs -> Record row -> FromScratch to
Instances
InputFieldsToFormFields Nil row ()
(IsSymbol name, Cons name (InputField e i o) trash row, InputFieldsToFormFields tail row from, Row1Cons name (FormField e i o) from to) => InputFieldsToFormFields (Cons name (InputField e i o) tail) row to
#FormFieldToMaybeOutput Source
class FormFieldToMaybeOutput (xs :: RowList) (row :: Row Type) (to :: Row Type) | xs -> to where
The class that provides the Builder implementation to efficiently transform the record of MaybeOutput to a record of OutputField, but only if all fs were successfully validated.
Members
formFieldsToMaybeOutputBuilder :: RLProxy xs -> Record row -> Maybe (FromScratch to)
Instances
FormFieldToMaybeOutput Nil row ()
(IsSymbol name, Cons name (FormField e i o) trash row, FormFieldToMaybeOutput tail row from, Row1Cons name (OutputField e i o) from to) => FormFieldToMaybeOutput (Cons name (FormField e i o) tail) row to
#CountErrors Source
class CountErrors (rl :: RowList) (r :: Row Type) where
A class to check if all fs in an FormField record have been touched or not
Members
countErrorsImpl :: RLProxy rl -> Record r -> Int
Instances
CountErrors Nil r
(IsSymbol name, Cons name (FormField e i o) t0 r, CountErrors tail r) => CountErrors (Cons name (FormField e i o) tail) r
#AllTouched Source
class AllTouched (rl :: RowList) (r :: Row Type) where
A class to check if all fs in an FormField record have been touched or not
Members
allTouchedImpl :: RLProxy rl -> Record r -> Boolean
Instances
AllTouched Nil r
(IsSymbol name, Cons name (FormField e i o) t0 r, AllTouched tail r) => AllTouched (Cons name (FormField e i o) tail) r
#ValidateAll Source
class ValidateAll (vs :: Row Type) (xs :: RowList) (row :: Row Type) (to :: Row Type) m | xs -> to where
A class that applies the current state to the unwrapped version of every validator
Members
validateAllBuilder :: Record vs -> RLProxy xs -> Record row -> m (FromScratch to)
Instances
(Monad m) => ValidateAll vs Nil row () m
(IsSymbol name, Monad m, Cons name (FormField e i o) t0 row, Newtype (form Record FormField) (Record row), Cons name (Validation form m e i o) t1 vs, Row1Cons name (FormField e i o) from to, ValidateAll vs tail row from m) => ValidateAll vs (Cons name (FormField e i o) tail) row to m
#ModifyAll Source
class ModifyAll (ifs :: Row Type) (xs :: RowList) (fs :: Row Type) (to :: Row Type) | xs -> to where
Members
modifyAllBuilder :: Record ifs -> RLProxy xs -> Record fs -> FromScratch to
Instances
ModifyAll ifs Nil fs ()
(IsSymbol name, Newtype (InputFunction e i o) (i -> i), Newtype (FormField e i o) (Record (FormFieldRow e i o)), Cons name (InputFunction e i o) trash0 ifs, Cons name (FormField e i o) trash1 row, Row1Cons name (FormField e i o) from to, ModifyAll ifs tail row from) => ModifyAll ifs (Cons name (FormField e i o) tail) row to
#ReplaceFormFieldInputs Source
class ReplaceFormFieldInputs (is :: Row Type) (xs :: RowList) (fs :: Row Type) (to :: Row Type) | xs -> to where
Members
replaceFormFieldInputsBuilder :: Record is -> RLProxy xs -> Record fs -> FromScratch to
Instances
ReplaceFormFieldInputs is Nil fs ()
(IsSymbol name, Newtype (InputField e i o) i, Newtype (FormField e i o) (Record (FormFieldRow e i o)), Cons name (InputField e i o) trash0 is, Cons name (FormField e i o) trash1 row, Row1Cons name (FormField e i o) from to, ReplaceFormFieldInputs is tail row from) => ReplaceFormFieldInputs is (Cons name (FormField e i o) tail) row to