Releases: react-hook-form/resolvers
Releases · react-hook-form/resolvers
v3.3.3
v3.3.2
v3.3.1
v3.3.0
v3.2.0
v3.1.1
3.1.1 (2023-06-12)
BREAKING CHANGES
Bug Fixes
You don't need to explicitly provide the type when using the useForm function because it automatically infers the types from the Yup schema.
Before
const schema = Yup.shape({ name: string });
const { register } = useForm<{name: string}>({ resolver: yupResolver(schema) });
After
const schema = Yup.shape({ name: string });
const { register } = useForm({ resolver: yupResolver(schema) });
v3.1.0
v3.0.1
v3.0.0
3.0.0 (2023-03-20)
BREAKING CHANGES
- Yup resolver require Yup v1
- rename
rawValues
option toraw
- classValidationResolver: schema options now includes validator and transformer options
- Please note that ajv and ajv-errors need to be installed separately, as they are not bundled with resolvers
Before:
schemaOptions?: ValidatorOptions,
After:
schemaOptions?: {
validator?: ValidatorOptions;
transformer?: ClassTransformOptions;
}
Bug Fixes
Features
- add option to keep raw values (f22d57c)
- classValidationResolver: add transform and validator options (#524) (2749bd9)
- yupResolver: add support Yup v1 (#520) (f3da212)
- typeboxResolver: add TypeBox resolver (#526) (6a31c92)
import { useForm } from 'react-hook-form';
import { typeboxResolver } from '@hookform/resolvers/typebox';
import { Type } from '@sinclair/typebox';
const schema = Type.Object({
username: Type.String({ minLength: 1 }),
password: Type.String({ minLength: 1 }),
});
const App = () => {
const { register, handleSubmit } = useForm({
resolver: typeboxResolver(schema),
});
return (
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input {...register('username')} />
<input type="password" {...register('password')} />
<input type="submit" />
</form>
);
};