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>
);
};