# @vorms/resolvers

> Vorms validation resolvers

Latest version **1.1.0** (published 2023-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vorms/resolvers
pnpm add @vorms/resolvers
yarn add @vorms/resolvers
bun add @vorms/resolvers
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-02-25 |
| First published | 2022-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 718 |
| Author | Alex Liu |
| Maintainers | mini-ghost |
| Keywords | scheme, validation, scheme-validation, yup, zod |

## Links

- npm: https://www.npmjs.com/package/@vorms/resolvers
- Repository: https://github.com/mini-ghost/vorms
- Homepage: https://github.com/mini-ghost/vorms#readme
- Issues: https://github.com/mini-ghost/vorms/issues
- npm.io page: https://npm.io/package/@vorms/resolvers

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-02-25
- 1.2.0-beta.5 (beta) — 2024-03-04
- 1.0.0-rc.2 (rc) — 2022-12-18
- 1.2.0-beta.4 — 2023-08-24
- 1.2.0-beta.3 — 2023-08-07
- 1.2.0-beta.2 — 2023-08-07
- 1.2.0-beta.1 — 2023-06-23
- 1.2.0-beta.0 — 2023-06-23
- 1.0.0 — 2023-01-08
- 1.0.0-rc.1 — 2022-11-19
- 0.0.1-beta.3 — 2022-07-15

## README

## Install

```bash
npm install @vorms/resolvers
```

## Quickstart

### [Yup](https://github.com/jquense/yup)

Dead simple Object schema validation

```vue
<script setup lang="ts">
import { useForm } from '@vorms/core';
import { yupResolver } from '@vorms/resolvers/yup';
import * as yup from 'yup'

const { register, errors, handleSubmit } = useForm({
  initialValues: {
    account: '',
    password: '',
  },
  validate: yupResolver(yup.object({
    account: yup.string().required(),
    password: yup.string().required()
  })),
  onSubmit(values) {
    alert(JSON.stringify(values, null, 2));
  },
});

const { value: account, attrs: accountAttrs } = register('account');
const { value: password, attrs: passwordAttrs } = register('password');
</script>

<template>
  <form @submit="handleSubmit">
    <div>
      <input
        v-model="account"
        type="text"
        placeholder="Account"
        v-bind="accountAttrs"
      />
      <div v-show="'account' in errors">
        {{ errors.account }}
      </div>
    </div>
    <div>
      <input
        v-model="password"
        type="password"
        placeholder="Password"
        v-bind="passwordAttrs"
      />
      <div v-show="'password' in errors">
        {{ errors.password }}
      </div>
    </div>
    <div>
      <input type="submit" />
    </div>
  </form>
</template>
```

### [Zod](https://github.com/vriad/zod)

TypeScript-first schema validation with static type inference

```vue
<script setup lang="ts">
import { useForm } from '@vorms/core';
import { zodResolver } from '@vorms/resolvers/zod';
import z from 'zod'

const { register, errors, handleSubmit } = useForm({
  initialValues: {
    account: '',
    password: '',
  },
  validate: yupResolver(z.object({
    account: z.string().min(1),
    password: z.string().min(1)
  })),
  onSubmit(values) {
    alert(JSON.stringify(values, null, 2));
  },
});

const { value: account, attrs: accountAttrs } = register('account');
const { value: password, attrs: passwordAttrs } = register('password');
</script>

<template>
  <form @submit="handleSubmit">
    <div>
      <input
        v-model="account"
        type="text"
        placeholder="Account"
        v-bind="accountAttrs"
      />
      <div v-show="'account' in errors">
        {{ errors.account }}
      </div>
    </div>
    <div>
      <input
        v-model="password"
        type="password"
        placeholder="Password"
        v-bind="passwordAttrs"
      />
      <div v-show="'password' in errors">
        {{ errors.password }}
      </div>
    </div>
    <div>
      <input type="submit" />
    </div>
  </form>
</template>
```

## Examples

- [Validate With Yup](https://stackblitz.com/edit/vorms-validate-with-yup?file=src%2FApp.vue)
- [Validate With Zod](https://stackblitz.com/edit/vorms-validate-with-zod?file=src%2FApp.vue)

## Credits

API inspired by [React Hook Form - Resolvers](https://github.com/react-hook-form/resolvers)

---
_Source: https://npm.io/package/@vorms/resolvers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
