@fun-land/react-validation
v2.0.0
Published
Helpers for using @fun-land/validation with ReactJS
Downloads
14
Maintainers
Readme
A set of helpers to make using @fun-land/validation
with React pleasant.
Usage
See @fun-land/validation for examples.
API
validateAndAct
<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)
TextInputState
interface TextInputState {
value: string
errorMessage: string
}
Interface for input[type=text]
and textarea
element state.
initTextInputState
;(value: string) => TextInputState
Helper to create a TextInputState instance
textInputValidator
(
testFunction: (value: string) => boolean,
errorTemplate: string | ((value: string) => string)
) => Validator<TextInputState>
Creates a Validator<TextInputState>
to work with text inputs and text areas.