Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.82 KB

_usevalidateassetter_.md

File metadata and controls

46 lines (32 loc) · 1.82 KB

react-uniformed"useValidateAsSetter"

Module: "useValidateAsSetter"

Index

Functions

Functions

useValidateAsSetter

useValidateAsSetter(validate: ValidateAllHandlerFieldValue›, values: Fields): eventLikeHandlers

Creates a function that accepts a name and value as parameters. When the returned function is invoked, it will call the specified validate function with the specified values merged in with the name and value passed to the invoked function.

The main purpose of this hook is to use validate with useSettersAsEventHandler without validation being one update behind.

example

// used with useForms
const {validate, values, setValue} = useForms(...);
const validateAll = useValidateAsSetter(validate, values);
// now you can use validate with onChange events and keep the validation
// in sync.
const onChange = useSettersAsEventHandler(setValue, validateAll);

Parameters:

Name Type Description
validate ValidateAllHandlerFieldValue a validation function that accepts an object of values.
values Fields a values object.

Returns: eventLikeHandlers

a function that can be invoked with a name and value.
See useSettersAsEventHandler
See useSettersAsRefEventHandler