A set of helpers to make using @fun-land/validation
with React pleasant.
See @fun-land/validation for examples.
<State>(
state: FunState<State>,
validator: Validator<State>,
action: (state: State) => unknown
) => void
Run validator on state an do an action if everything is good.
Example:
validateAndAct(formState, formValidator, postForm)
interface TextInputState {
value: string
errorMessage: string
}
Interface for input[type=text]
and textarea
element state.
;(value: string) => TextInputState
Helper to create a TextInputState instance
(
testFunction: (value: string) => boolean,
errorTemplate: string | ((value: string) => string)
) => Validator<TextInputState>
Creates a Validator<TextInputState>
to work with text inputs and text areas.