0

I'd like to add a custom validator to RegisterOptions from react-hook-form. Just like valueAsNumber and valueAsDate. I'd like to create it globally, so I have the option everywhere in my code. I'm using TypeScript. Now I'd like to use it like this:

register("name", { valueAsNullableString: true }

Where valueAsNullableString is:

function valueAsNullableString(value: string): string | null {
    return value ? value : null;
}
julian.a
  • 1,163
  • 2
  • 9
  • 21

0 Answers0