@br-validators/react-hook-form
v1.8.2
Published
React Hook Form rules and resolvers for Brazilian document validators — delegates to @br-validators/core
Downloads
951
Maintainers
Readme
@br-validators/react-hook-form
React Hook Form rules and resolvers that delegate to @br-validators/core v1.8.2.
Install
pnpm add @br-validators/react-hook-form @br-validators/core react react-hook-formRegister + validate rule
import { useForm } from 'react-hook-form';
import { cpfRule } from '@br-validators/react-hook-form';
const { register } = useForm<{ cpf: string }>();
<input {...register('cpf', cpfRule({ required: 'CPF is required' }))} />;Resolver
import { useForm } from 'react-hook-form';
import { cpfResolver } from '@br-validators/react-hook-form';
const form = useForm<{ cpf: string }>({ resolver: cpfResolver() });Invalid values surface the same message string returned by core validate*.
License
MIT
