@hookform/resolvers
Advanced tools
Comparing version 2.6.1 to 2.7.0
{ | ||
"name": "@hookform/resolvers", | ||
"amdName": "hookformResolvers", | ||
"version": "2.6.1", | ||
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope and computed-types", | ||
"version": "2.7.0", | ||
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types and Typanion", | ||
"main": "dist/resolvers.js", | ||
@@ -72,2 +72,8 @@ "module": "dist/resolvers.module.js", | ||
}, | ||
"./typanion": { | ||
"browser": "./typanion/dist/typanion.module.js", | ||
"umd": "./typanion/dist/typanion.umd.js", | ||
"import": "./typanion/dist/typanion.mjs", | ||
"require": "./typanion/dist/typanion.js" | ||
}, | ||
"./package.json": "./package.json", | ||
@@ -104,3 +110,6 @@ "./": "./" | ||
"computed-types/src", | ||
"computed-types/dist" | ||
"computed-types/dist", | ||
"typanion/package.json", | ||
"typanion/src", | ||
"typanion/dist" | ||
], | ||
@@ -123,2 +132,3 @@ "publishConfig": { | ||
"build:computed-types": "microbundle --cwd computed-types --globals '@hookform/resolvers=hookformResolvers'", | ||
"build:typanion": "microbundle --cwd typanion --globals '@hookform/resolvers=hookformResolvers'", | ||
"postbuild": "node ./config/node-13-exports.js", | ||
@@ -146,3 +156,4 @@ "lint": "eslint . --ext .ts,.js --ignore-path .gitignore", | ||
"nope", | ||
"computed-types" | ||
"computed-types", | ||
"typanion" | ||
], | ||
@@ -192,2 +203,3 @@ "repository": { | ||
"ts-jest": "^27.0.1", | ||
"typanion": "^3.3.2", | ||
"typescript": "^4.3.2", | ||
@@ -194,0 +206,0 @@ "vest": "^3.2.3", |
@@ -23,2 +23,6 @@ <div align="center"> | ||
## Links | ||
- [React-hook-form validation resolver documentation ](https://react-hook-form.com/api/useform/#validationResolver) | ||
## API | ||
@@ -159,3 +163,4 @@ | ||
const schema = Joi.object({ | ||
username: Joi.string().required(), | ||
name: Joi.string().required(), | ||
age: Joi.number().required(), | ||
}); | ||
@@ -377,4 +382,3 @@ | ||
username: string.min(1).error('username field is required'), | ||
password: string.min(1).error('password field is required'), | ||
password: number, | ||
age: number, | ||
}); | ||
@@ -405,2 +409,42 @@ | ||
### [typanion](https://github.com/arcanis/typanion) | ||
Static and runtime type assertion library with no dependencies | ||
[![npm](https://img.shields.io/bundlephobia/minzip/typanion?style=for-the-badge)](https://bundlephobia.com/result?p=typanion) | ||
```tsx | ||
import React from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import { typanionResolver } from '@hookform/resolvers/typanion'; | ||
import * as t from 'typanion'; | ||
const isUser = t.isObject({ | ||
username: t.applyCascade(t.isString(), [t.hasMinLength(1)]), | ||
age: t.applyCascade(t.isNumber(), [t.isInteger(), t.isInInclusiveRange(1, 100)]), | ||
}); | ||
const App = () => { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors }, | ||
} = useForm({ | ||
resolver: typanionResolver(isUser), | ||
}); | ||
return ( | ||
<form onSubmit={handleSubmit((d) => console.log(d))}> | ||
<input {...register('name')} /> | ||
{errors.name?.message && <p>{errors.name?.message}</p>} | ||
<input type="number" {...register('age')} /> | ||
{errors.age?.message && <p>{errors.age?.message}</p>} | ||
<input type="submit" /> | ||
</form> | ||
); | ||
}; | ||
export default App; | ||
``` | ||
## Backers | ||
@@ -407,0 +451,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375450
228
3636
469
37
22