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