resolvers

📋 Validation resolvers: Yup, Zod, AJV, Joi, Superstruct, Vest, class-validator, io-ts, typanion, Ajv, TypeBox, Valibot and nope.

MIT License

Downloads
14.5M
Stars
1.6K
Committers
51

Bot releases are visible (Hide)

resolvers - v2.0.0-beta.8

Published by github-actions[bot] over 3 years ago

2.0.0-beta.8 (2021-02-02)

Bug Fixes

resolvers - v1.3.4

Published by github-actions[bot] over 3 years ago

1.3.4 (2021-02-02)

Bug Fixes

resolvers - v1.3.3

Published by github-actions[bot] over 3 years ago

1.3.3 (2021-01-31)

Bug Fixes

  • expose array element validation errors in zod resolver (#119) (ecee1e9)
resolvers - v2.0.0-beta.7

Published by github-actions[bot] over 3 years ago

2.0.0-beta.7 (2021-01-28)

Features

  • update to react-hook-form v7 (5fdc7f9)

BREAKING CHANGES

  • Require react-hook-form >= 7
resolvers - v2.0.0-beta.6

Published by github-actions[bot] over 3 years ago

2.0.0-beta.6 (2021-01-23)

Features

  • add Vest sync validation + update to v3 (#117) (e76743d)
resolvers - v2.0.0-beta.5

Published by github-actions[bot] over 3 years ago

2.0.0-beta.5 (2021-01-22)

Features

resolvers - v2.0.0-beta.4

Published by github-actions[bot] over 3 years ago

2.0.0-beta.4 (2021-01-21)

Features

resolvers - v2.0.0-beta.3

Published by github-actions[bot] almost 4 years ago

2.0.0-beta.3 (2021-01-05)

Bug Fixes

  • yup resolver typescript errors (8e10721)
resolvers - v2.0.0-beta.2

Published by github-actions[bot] almost 4 years ago

2.0.0-beta.2 (2021-01-05)

Features

  • improve modules support (507ee0d)
resolvers - v2.0.0-beta.1

Published by github-actions[bot] almost 4 years ago

2.0.0-beta.1 (2021-01-05)

Features

BREAKING CHANGES

  • there will be some breaking changes in the next versions
resolvers - v1.3.2

Published by github-actions[bot] almost 4 years ago

1.3.2 (2021-01-04)

Bug Fixes

resolvers - Version 1.3.1

Published by bluebill1049 almost 4 years ago

esm support to fix bundler incompatibility (#95)

resolvers - Version 1.3.0

Published by bluebill1049 almost 4 years ago

Support Yup ^0.32.0 (#92)

resolvers - Version 1.2.0

Published by bluebill1049 almost 4 years ago

vestResolver (#82)

import * as React from 'react';
import { useForm } from 'react-hook-form';
import { vestResolver } from '@hookform/resolvers/vest';
import vest, { test, enforce } from 'vest';

const validationSuite = vest.create((data = {}) => {
  test('username', 'Username is required', () => {
    enforce(data.username).isNotEmpty();
  });

  test('username', 'Must be longer than 3 chars', () => {
    enforce(data.username).longerThan(3);
  });

  test('password', 'Password is required', () => {
    enforce(data.password).isNotEmpty();
  });

  test('password', 'Password must be at least 5 chars', () => {
    enforce(data.password).longerThanOrEquals(5);
  });

  test('password', 'Password must contain a digit', () => {
    enforce(data.password).matches(/[0-9]/);
  });

  test('password', 'Password must contain a symbol', () => {
    enforce(data.password).matches(/[^A-Za-z0-9]/);
  });
});

const App = () => {
  const { register, handleSubmit, errors } = useForm({
    resolver: vestResolver(validationSuite),
  });

  return (
    <form onSubmit={handleSubmit((data) => console.log(data))}>
      <input type="text" name="username" ref={register} />
      <input type="text" name="password" ref={register} />
      <input type="submit" />
    </form>
  );
};
resolvers - Version 1.1.2

Published by bluebill1049 almost 4 years ago

fix: superstruct filename typo (#89)

resolvers - Version 1.1.1

Published by bluebill1049 almost 4 years ago

fix: IE11 build (#85)

resolvers - Version 1.1.0

Published by bluebill1049 almost 4 years ago

Update Superstruct version (#83)

resolvers - Version 1.0.1

Published by bluebill1049 almost 4 years ago

  • build: add TS declaration file to ie11 build (#72)
  • Use right version of react-hook-form for ie11 bundle (#68)
resolvers - Version 1.0.0

Published by bluebill1049 about 4 years ago

🎉 Resolver version 1.0.0 is LIVE.

resolvers - Version v1.0.0-rc.2

Published by bluebill1049 about 4 years ago

🎉 Zod resolver

import React from 'react';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import * as z from 'zod';

const schema = z.object({
  username: z.string(),
});

const App = () => {
  const { register, handleSubmit } = useForm({
    resolver: zodResolver(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>
  );
};
Package Rankings
Top 1.0% on Npmjs.org
Badges
Extracted from project README
npm downloads npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm
Related Projects