@hookform/resolvers
Advanced tools
Comparing version 2.8.10 to 2.9.0
{ | ||
"name": "@hookform/resolvers", | ||
"amdName": "hookformResolvers", | ||
"version": "2.8.10", | ||
"version": "2.9.0", | ||
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types and Typanion", | ||
@@ -78,2 +78,8 @@ "main": "dist/resolvers.js", | ||
}, | ||
"./ajv": { | ||
"browser": "./ajv/dist/ajv.module.js", | ||
"umd": "./ajv/dist/ajv.umd.js", | ||
"import": "./ajv/dist/ajv.mjs", | ||
"require": "./ajv/dist/ajv.js" | ||
}, | ||
"./package.json": "./package.json", | ||
@@ -113,3 +119,6 @@ "./*": "./*" | ||
"typanion/src", | ||
"typanion/dist" | ||
"typanion/dist", | ||
"ajv/package.json", | ||
"ajv/src", | ||
"ajv/dist" | ||
], | ||
@@ -133,2 +142,3 @@ "publishConfig": { | ||
"build:typanion": "microbundle --cwd typanion --globals '@hookform/resolvers=hookformResolvers'", | ||
"build:ajv": "microbundle --cwd ajv --globals '@hookform/resolvers=hookformResolvers'", | ||
"postbuild": "node ./config/node-13-exports.js", | ||
@@ -157,3 +167,4 @@ "lint": "eslint . --ext .ts,.js --ignore-path .gitignore", | ||
"computed-types", | ||
"typanion" | ||
"typanion", | ||
"ajv" | ||
], | ||
@@ -178,2 +189,4 @@ "repository": { | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"ajv": "^8.11.0", | ||
"ajv-errors": "^3.0.0", | ||
"check-export-map": "^1.2.0", | ||
@@ -180,0 +193,0 @@ "class-transformer": "^0.5.1", |
@@ -30,9 +30,9 @@ <div align="center"> | ||
``` | ||
type Options = { | ||
type Options = { | ||
mode: 'async' | 'sync', | ||
rawValues?: boolean | ||
rawValues?: boolean | ||
} | ||
resolver(schema: object, schemaOptions?: object, resolverOptions: Options) | ||
```` | ||
``` | ||
@@ -409,2 +409,52 @@ | | type | Required | Description | | ||
### [Ajv](https://github.com/ajv-validator/ajv) | ||
The fastest JSON validator for Node.js and browser | ||
[![npm](https://img.shields.io/bundlephobia/minzip/ajv?style=for-the-badge)](https://bundlephobia.com/result?p=ajv) | ||
```tsx | ||
import { useForm } from 'react-hook-form'; | ||
import { ajvResolver } from '@hookform/resolvers/ajv'; | ||
// must use `minLength: 1` to implement required field | ||
const schema = { | ||
type: 'object', | ||
properties: { | ||
username: { | ||
type: 'string', | ||
minLength: 1, | ||
errorMessage: { minLength: 'username field is required' }, | ||
}, | ||
password: { | ||
type: 'string', | ||
minLength: 1, | ||
errorMessage: { minLength: 'password field is required' }, | ||
}, | ||
}, | ||
required: ['username', 'password'], | ||
additionalProperties: false, | ||
}; | ||
const App = () => { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors }, | ||
} = useForm({ | ||
resolver: ajvResolver(schema), | ||
}); | ||
return ( | ||
<form onSubmit={handleSubmit((data) => console.log(data))}> | ||
<input {...register('username')} /> | ||
{errors.username && <span>{errors.username.message}</span>} | ||
<input {...register('password')} /> | ||
{errors.password && <span>{errors.password.message}</span>} | ||
<button type="submit">submit</button> | ||
</form> | ||
); | ||
}; | ||
``` | ||
## Backers | ||
@@ -411,0 +461,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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
2865199
248
6478
481
39
24
5