formik-validator-zod 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,6 +3,11 @@
3
3
  Allows you to easily validate [Formik](https://github.com/jaredpalmer/formik)
4
4
  forms with the power of [Zod](https://github.com/colinhacks/zod) schemas.
5
5
 
6
+ WARNING: As of v2, this package uses native ESM and no longer provides a
7
+ CommonJS export. If this is something you need, you should be able to use the
8
+ [dynamic import](https://v8.dev/features/dynamic-import) function or use v1 of
9
+ this package.
10
+
6
11
  ## Installation
7
12
 
8
13
  ```sh
package/dist/index.js CHANGED
@@ -1,17 +1,3 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.withZodSchema = void 0;
15
1
  /**
16
2
  * Allows you to easily use Zod schemas with the <Formik /> component `validate`
17
3
  * prop.
@@ -20,16 +6,12 @@ exports.withZodSchema = void 0;
20
6
  * <Formik {...} validate={withZodSchema(yourSchema)}>
21
7
  * ```
22
8
  */
23
- var withZodSchema = function (schema, params) {
24
- return function (values) {
25
- var result = schema.safeParse(values, params);
26
- if (result.success)
27
- return {};
28
- return result.error.issues.reduce(function (acc, curr) {
29
- var _a;
30
- var key = curr.path.join('.');
31
- return __assign(__assign({}, acc), (_a = {}, _a[key] = curr.message, _a));
32
- }, {});
33
- };
9
+ export const withZodSchema = (schema, params) => (values) => {
10
+ const result = schema.safeParse(values, params);
11
+ if (result.success)
12
+ return {};
13
+ return result.error.issues.reduce((acc, curr) => {
14
+ const key = curr.path.join('.');
15
+ return Object.assign(Object.assign({}, acc), { [key]: curr.message });
16
+ }, {});
34
17
  };
35
- exports.withZodSchema = withZodSchema;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "formik-validator-zod",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "Helper to simplify validating Formik values with Zod",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {
@@ -16,7 +17,7 @@
16
17
  "schema",
17
18
  "validation"
18
19
  ],
19
- "author": "Luke Glazebrook <Glazy@users.noreply.github.com> (https://glazebrook.dev)",
20
+ "author": "Luke Glazebrook <Glazy@users.noreply.github.com>",
20
21
  "repository": {
21
22
  "type": "git",
22
23
  "url": "https://github.com/glazy/formik-validator-zod.git"