revalidate
revalidate copied to clipboard
How to get field value in message creator function?
Thank you for this library.
I'm trying to create a custom validator using createValidator
helper
In the message I need use current value, how to achieve this?
It looks something like this
const myValidator = createValidator(
message => value => message,
(field, value) => `${field} has value ${value}`
);
Experiments today and find that. Return function instead of string, and apply value in validator implementation. What pitfalls are there?
const myValidator = createValidator(
message => value => message(value),
(field) => (value) => `${field} has value ${value}`
);