Skip to content

Commit

Permalink
feat: add VineJS resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
lahgolz committed May 13, 2024
1 parent ed5457a commit 44ca5ae
Show file tree
Hide file tree
Showing 12 changed files with 660 additions and 13 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- [ArkType](#arktype)
- [Valibot](#valibot)
- [effect-ts](#effect-ts)
- [VineJS](#vinejs)
- [Backers](#backers)
- [Sponsors](#sponsors)
- [Contributors](#contributors)
Expand Down Expand Up @@ -628,6 +629,41 @@ function TestComponent({ onSubmit }: Props) {
}
```

### [VineJS](https://github.com/vinejs/vine)

VineJS is a form data validation library for Node.js

[![npm](https://img.shields.io/bundlephobia/minzip/@vinejs/vine?style=for-the-badge)](https://bundlephobia.com/result?p=@vinejs/vine)

```typescript jsx
import { useForm } from 'react-hook-form';
import { vineResolver } from '@hookform/resolvers/vine';
import vine from '@vinejs/vine';

const schema = vine.compile(
vine.object({
username: vine.string().minLength(1),
password: vine.string().minLength(1),
}),
);

const App = () => {
const { register, handleSubmit } = useForm({
resolver: vineResolver(schema),
});

return (
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input {...register('username')} />
{errors.username && <span role="alert">{errors.username.message}</span>}
<input {...register('password')} />
{errors.password && <span role="alert">{errors.password.message}</span>}
<button type="submit">submit</button>
</form>
);
};
```

## Backers

Thanks goes to all our backers! [[Become a backer](https://opencollective.com/react-hook-form#backer)].
Expand Down
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@hookform/resolvers",
"amdName": "hookformResolvers",
"version": "2.9.1",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype, Typanion and Effect-TS",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype, Typanion, Effect-TS and VineJS",
"main": "dist/resolvers.js",
"module": "dist/resolvers.module.js",
"umd:main": "dist/resolvers.umd.js",
Expand Down Expand Up @@ -105,6 +105,12 @@
"import": "./effect-ts/dist/effect-ts.mjs",
"require": "./effect-ts/dist/effect-ts.js"
},
"./vine": {
"types": "./vine/dist/index.d.ts",
"umd": "./vine/dist/vine.umd.js",
"import": "./vine/dist/vine.mjs",
"require": "./vine/dist/vine.js"
},
"./package.json": "./package.json",
"./*": "./*"
},
Expand Down Expand Up @@ -154,7 +160,10 @@
"valibot/dist",
"effect-ts/package.json",
"effect-ts/src",
"effect-ts/dist"
"effect-ts/dist",
"vine/package.json",
"vine/src",
"vine/dist"
],
"publishConfig": {
"access": "public"
Expand All @@ -178,6 +187,7 @@
"build:arktype": "microbundle --cwd arktype --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
"build:valibot": "microbundle --cwd valibot --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
"build:effect-ts": "microbundle --cwd effect-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@effect/schema=EffectSchema,@effect/schema/AST=EffectSchemaAST,@effect/schema/ArrayFormatter=EffectSchemaArrayFormatter",
"build:vine": "microbundle --cwd vine --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
"postbuild": "node ./config/node-13-exports.js",
"lint": "eslint . --ext .ts,.js --ignore-path .gitignore",
"lint:types": "tsc",
Expand Down Expand Up @@ -207,7 +217,8 @@
"typanion",
"ajv",
"TypeBox",
"arktype"
"arktype",
"vine"
],
"repository": {
"type": "git",
Expand All @@ -230,6 +241,7 @@
"@types/react": "^18.2.20",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vinejs/vine": "^2.0.0",
"@vitejs/plugin-react": "^4.0.4",
"ajv": "^8.12.0",
"ajv-errors": "^3.0.0",
Expand Down
77 changes: 67 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@hookform/resolvers/vine",
"amdName": "hookformResolversVine",
"version": "1.0.0",
"private": true,
"description": "React Hook Form validation resolver: vine",
"main": "dist/vine.js",
"module": "dist/vine.module.js",
"umd:main": "dist/vine.umd.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"license": "MIT",
"peerDependencies": {
"react-hook-form": "^7.0.0",
"@hookform/resolvers": "^2.0.0",
"@vinejs/vine": "^2.0.0"
}
}
Loading

0 comments on commit 44ca5ae

Please sign in to comment.