Releases: react-hook-form/resolvers
Releases · react-hook-form/resolvers
v2.4.0
2.4.0 (2021-04-17)
Features
import React from 'react';
import { useForm } from 'react-hook-form';
import { nopeResolver } from '@hookform/resolvers/nope';
import Nope from 'nope-validator';
const schema = Nope.object().shape({
name: Nope.string().required(),
age: Nope.number().required(),
});
const App = () => {
const { register, handleSubmit } = useForm({
resolver: nopeResolver(schema),
});
return (
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input name="name" ref={register} />
<input name="age" type="number" ref={register} />
<input type="submit" />
</form>
);
};
export default App;
v2.3.2
v2.3.1
v2.3.0
2.3.0 (2021-04-13)
Features
import React from 'react';
import { useForm } from 'react-hook-form';
import { ioTsResolver } from '@hookform/resolvers/io-ts';
import t from 'io-ts';
// you don't have to use io-ts-types but it's very useful
import tt from 'io-ts-types';
const schema = t.type({
username: t.string,
age: tt.NumberFromString,
});
const App = () => {
const { register, handleSubmit } = useForm({
resolver: ioTsResolver(schema),
});
return (
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input name="username" ref={register} />
<input name="age" type="number" ref={register} />
<input type="submit" />
</form>
);
};
export default App;
v2.2.0
v2.1.0
2.1.0 (2021-04-09)
Features
- class-validator resolver 🎉 (#147) (defa00b) Huge thanks to @mzalevski
import 'reflect-metadata';
import React from 'react';
import { useForm } from 'react-hook-form';
import { classValidatorResolver } from '@hookform/resolvers/class-validator';
import { Length, Min, IsEmail } from 'class-validator';
class User {
@Length(2, 30)
username: string;
@Min(18)
age: number;
@IsEmail()
email: string;
}
const App = () => {
const {
register,
handleSubmit,
formState: { errors },
} = useForm<User>({ resolver: classValidatorResolver(User) });
return (
<form onSubmit={handleSubmit((data) => console.log(data))} >
<input type="text" {...register('username')} />
{errors.username && <span>{errors.username.message}</span>}
<input type="text" {...register('email')} />
{errors.email && <span>{errors.email.message}</span>}
<input type="number" {...register('age', { valueAsNumber: true })} />
{errors.age && <span>{errors.age.message}</span>}
<input type="submit" value="Submit" />
</form>
);
};
export default App;
v2.0.1
v2.0.0
2.0.0 (2021-04-02)
BREAKING CHANGES
- Require react-hook-form >= 7
Features
- Pass down error's ref (#127) (fd9c5bc)
- expose array element validation errors in zod resolver (#119) (ecee1e9)
- types: add Lazy schema support to resolver (#135) (ac2128e), closes #92 #31
- Vest sync validation + update to v3 (#117) (e76743d)
- Joi sync validation (#116) (8e3b54a)
- Yup sync validation (#115) (f83996b)
- Zod async validation (#114) (22e7545)
Bug Fixes
- Joi pass down context from useForm (#122) (132a90e)
- zod union error + reduce size (#126) (19dfa9b)
- yup resolver typescript errors (8e10721)
- Improve modules support (cjs, esm, umd) (507ee0d)
Performance Improvements
- reduce joi resolver's size (#131) (3af7bd7)
- reduce yup resolver's size (#130) (de0b62a)
- reduce vest resolver size (#129) (6e86b4f)
- reduce joi and yup bundle size (#134) (635344d)
V2 🚀 (#108) (fe53179), closes #108 #97 #114 #116 #115 #117 #123 #125 #124 #126 #127 #128 #129 #131 #130 #132 #134 #136