Repository: logaretm/vee-validate
Pull request #4880 (2024-10-04 16:07:52)

chore: update valibot dependency to v1
I've updated the Valibot dependency for Vee Validate to v1. We've changed the type signature, so this change is necessary. All other changes in our v1 beta version are only internal.

---

An union of schema library authors (Zod, Valibot, ArkType, ...) collaborating on a standard interface for schema libraries called [Standard Schema](https://github.com/standard-schema/standard-schema). This simplifies implementation and prevents vendor lock-in. So far Valibot v1 supports this spec and Zod will follow soon. In the long run, the explicit implementation of a Valibot and Zod adapter may no longer be necessary.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/logaretm/vee-validate/pull/4880?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 89.76%. Comparing base [(`3d2ec93`)](https://app.codecov.io/gh/logaretm/vee-validate/commit/3d2ec93a1b81b629bfb4b40e3d1841b7aa54a361?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad) to head [(`ebfc49c`)](https://app.codecov.io/gh/logaretm/vee-validate/commit/ebfc49c8e58607ac3bc919dde12d2c5f0a113699?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #4880   +/-   ##
=======================================
  Coverage   89.76%   89.76%           
=======================================
  Files          93       93           
  Lines        7887     7887           
  Branches     1376     1376           
=======================================
  Hits         7080     7080           
  Misses        800      800           
  Partials        7        7           
```

| [Flag](https://app.codecov.io/gh/logaretm/vee-validate/pull/4880/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad) | Coverage Δ | |
|---|---|---|
| [](https://app.codecov.io/gh/logaretm/vee-validate/pull/4880/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad) | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/logaretm/vee-validate/pull/4880?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abdelrahman+Awad).


Patch:
diff --git a/.changeset/beige-mirrors-smoke.md b/.changeset/beige-mirrors-smoke.md
new file mode 100644
index 00000000..e4ade112
--- /dev/null
+++ b/.changeset/beige-mirrors-smoke.md
@@ -0,0 +1,5 @@
+---
+"@vee-validate/rules": patch
+---
+
+fix: incorrect shared type import in rules
diff --git a/.changeset/famous-guests-march.md b/.changeset/famous-guests-march.md
new file mode 100644
index 00000000..b6c9f792
--- /dev/null
+++ b/.changeset/famous-guests-march.md
@@ -0,0 +1,11 @@
+---
+"vee-validate": patch
+"@vee-validate/valibot": patch
+"@vee-validate/rules": patch
+"@vee-validate/i18n": patch
+"@vee-validate/joi": patch
+"@vee-validate/yup": patch
+"@vee-validate/zod": patch
+---
+
+chore: add 'exports' field in package.json for all packages
diff --git a/packages/i18n/package.json b/packages/i18n/package.json
index 427835cd..f19cd76d 100644
--- a/packages/i18n/package.json
+++ b/packages/i18n/package.json
@@ -9,6 +9,13 @@
   "unpkg": "dist/vee-validate-i18n.js",
   "main": "dist/vee-validate-i18n.js",
   "types": "dist/vee-validate-i18n.d.ts",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-i18n.d.ts",
+      "import": "./dist/vee-validate-i18n.esm.js",
+      "require": "./dist/vee-validate-i18n.js"
+    }
+  },
   "sideEffects": false,
   "files": [
     "dist/*.js",
diff --git a/packages/joi/package.json b/packages/joi/package.json
index 86dc6ecf..57bbd442 100644
--- a/packages/joi/package.json
+++ b/packages/joi/package.json
@@ -8,6 +8,13 @@
   "unpkg": "dist/vee-validate-joi.js",
   "main": "dist/vee-validate-joi.js",
   "types": "dist/vee-validate-joi.d.ts",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-joi.d.ts",
+      "import": "./dist/vee-validate-joi.esm.js",
+      "require": "./dist/vee-validate-joi.js"
+    }
+  },
   "homepage": "https://vee-validate.logaretm.com/v4/integrations/joi-schema-validation/",
   "repository": {
     "url": "https://github.com/logaretm/vee-validate.git",
diff --git a/packages/rules/package.json b/packages/rules/package.json
index c55e4990..8219387e 100644
--- a/packages/rules/package.json
+++ b/packages/rules/package.json
@@ -8,6 +8,13 @@
   "unpkg": "dist/vee-validate-rules.js",
   "main": "dist/vee-validate-rules.js",
   "types": "dist/vee-validate-rules.d.ts",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-rules.d.ts",
+      "import": "./dist/vee-validate-rules.esm.js",
+      "require": "./dist/vee-validate-rules.js"
+    }
+  },
   "homepage": "https://vee-validate.logaretm.com/v4/guide/global-validators",
   "repository": {
     "url": "https://github.com/logaretm/vee-validate.git",
diff --git a/packages/rules/src/index.ts b/packages/rules/src/index.ts
index 1f0cbc82..5d37a31f 100644
--- a/packages/rules/src/index.ts
+++ b/packages/rules/src/index.ts
@@ -26,7 +26,7 @@ import required from './required';
 import size from './size';
 import url from './url';
 import { toTypedSchema } from './toTypedSchema';
-import { SimpleValidationRuleFunction } from 'packages/shared';
+import { SimpleValidationRuleFunction } from '../../shared/types';
 
 export const all: Record<string, SimpleValidationRuleFunction<any, any>> = {
   alpha_dash,
diff --git a/packages/valibot/package.json b/packages/valibot/package.json
index a77352a8..4ec7b746 100644
--- a/packages/valibot/package.json
+++ b/packages/valibot/package.json
@@ -7,6 +7,13 @@
   "module": "dist/vee-validate-valibot.esm.js",
   "unpkg": "dist/vee-validate-valibot.js",
   "main": "dist/vee-validate-valibot.js",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-valibot.d.ts",
+      "import": "./dist/vee-validate-valibot.esm.js",
+      "require": "./dist/vee-validate-valibot.js"
+    }
+  },
   "types": "dist/vee-validate-valibot.d.ts",
   "homepage": "https://vee-validate.logaretm.com/v4/integrations/zod-schema-validation/",
   "repository": {
@@ -29,7 +36,7 @@
   ],
   "dependencies": {
     "type-fest": "^4.8.3",
-    "valibot": "^0.33.0",
+    "valibot": "1.0.0-beta.0",
     "vee-validate": "workspace:*"
   }
 }
diff --git a/packages/vee-validate/package.json b/packages/vee-validate/package.json
index 0a6547e1..c1b9bff8 100644
--- a/packages/vee-validate/package.json
+++ b/packages/vee-validate/package.json
@@ -7,6 +7,13 @@
   "module": "dist/vee-validate.esm.js",
   "unpkg": "dist/vee-validate.js",
   "main": "dist/vee-validate.js",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate.d.ts",
+      "import": "./dist/vee-validate.esm.js",
+      "require": "./dist/vee-validate.js"
+    }
+  },
   "types": "dist/vee-validate.d.ts",
   "homepage": "https://vee-validate.logaretm.com/",
   "repository": {
diff --git a/packages/vee-validate/src/validate.ts b/packages/vee-validate/src/validate.ts
index 4bda8976..aea92657 100644
--- a/packages/vee-validate/src/validate.ts
+++ b/packages/vee-validate/src/validate.ts
@@ -310,7 +310,7 @@ export async function validateTypedSchema<TValues extends GenericObject, TOutput
   values: TValues,
 ): Promise<FormValidationResult<TValues, TOutput>> {
   const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
-  const validationResult = await typedSchema.parse(deepCopy(values));
+  const validationResult = await typedSchema.parse(deepCopy(values), { formData: deepCopy(values) });
 
   const results: Partial<FlattenAndMapPathsValidationResult<TValues, TOutput>> = {};
   const errors: Partial<Record<Path<TValues>, string>> = {};
diff --git a/packages/yup/package.json b/packages/yup/package.json
index 9b081025..58404cf1 100644
--- a/packages/yup/package.json
+++ b/packages/yup/package.json
@@ -8,6 +8,13 @@
   "unpkg": "dist/vee-validate-yup.js",
   "main": "dist/vee-validate-yup.js",
   "types": "dist/vee-validate-yup.d.ts",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-yup.d.ts",
+      "import": "./dist/vee-validate-yup.esm.js",
+      "require": "./dist/vee-validate-yup.js"
+    }
+  },
   "homepage": "https://vee-validate.logaretm.com/v4/guide/composition-api/typed-schema/",
   "repository": {
     "url": "https://github.com/logaretm/vee-validate.git",
diff --git a/packages/zod/package.json b/packages/zod/package.json
index aca4b1be..68d3f27f 100644
--- a/packages/zod/package.json
+++ b/packages/zod/package.json
@@ -8,6 +8,13 @@
   "unpkg": "dist/vee-validate-zod.js",
   "main": "dist/vee-validate-zod.js",
   "types": "dist/vee-validate-zod.d.ts",
+  "exports": {
+    ".": {
+      "types": "./dist/vee-validate-zod.d.ts",
+      "import": "./dist/vee-validate-zod.esm.js",
+      "require": "./dist/vee-validate-zod.js"
+    }
+  },
   "homepage": "https://vee-validate.logaretm.com/v4/integrations/zod-schema-validation/",
   "repository": {
     "url": "https://github.com/logaretm/vee-validate.git",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 65f5bb20..38338f4d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -282,8 +282,8 @@ importers:
         specifier: ^4.8.3
         version: 4.8.3
       valibot:
-        specifier: ^0.33.0
-        version: 0.33.3
+        specifier: 1.0.0-beta.0
+        version: 1.0.0-beta.0(typescript@5.4.5)
       vee-validate:
         specifier: workspace:*
         version: link:../vee-validate
@@ -7313,6 +7313,14 @@ packages:
   valibot@0.33.3:
     resolution: {integrity: sha512-/fuY1DlX8uiQ7aphlzrrI2DbG0YJk84JMgvz2qKpUIdXRNsS53varfo4voPjSrjUr5BSV2K0miSEJUOlA5fQFg==}
 
+  valibot@1.0.0-beta.0:
+    resolution: {integrity: sha512-Q/oine+NPMXdIy3vwluw0vidHLk0mTPUQBRHc+EHZXnEWF3KzLx1YLsVHPVrgHaMGRfV58P9eGOgxJvi0a059w==}
+    peerDependencies:
+      typescript: '>=5'
+    peerDependenciesMeta:
+      typescript:
+        optional: true
+
   validate-npm-package-license@3.0.4:
     resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}
 
@@ -16530,6 +16538,10 @@ snapshots:
 
   valibot@0.33.3: {}
 
+  valibot@1.0.0-beta.0(typescript@5.4.5):
+    optionalDependencies:
+      typescript: 5.4.5
+
   validate-npm-package-license@3.0.4:
     dependencies:
       spdx-correct: 3.2.0


Test patch:
diff --git a/packages/vee-validate/tests/Form.spec.ts b/packages/vee-validate/tests/Form.spec.ts
index 607e7e9c..596fa8d9 100644
--- a/packages/vee-validate/tests/Form.spec.ts
+++ b/packages/vee-validate/tests/Form.spec.ts
@@ -3222,3 +3222,48 @@ test('provides form values as yup context refs', async () => {
   expect(pwError?.textContent).toBeFalsy();
   expect(cpwError?.textContent).toBeFalsy();
 });
+
+test('provides form values as yup context refs for schema validation', async () => {
+  mountWithHoc({
+    setup() {
+      const validationSchema = yup.object({
+        password: yup.string().required().min(3).label('Password'),
+        confirmPassword: yup
+          .string()
+          .required()
+          .oneOf([yup.ref('$password')])
+          .label('Confirm Password'),
+      });
+
+      return {
+        validationSchema,
+      };
+    },
+    template: `
+      <VForm  v-slot="{ errors }" :validation-schema="validationSchema">
+        <Field id="password" name="password" type="password" />
+        <span id="passwordErr">{{ errors.password }}</span>
+
+        <Field id="confirmPassword" name="confirmPassword" type="password" />
+        <span id="confirmPasswordErr">{{ errors.confirmPassword }}</span>
+
+        <button>Validate</button>
+      </VForm>
+    `,
+  });
+
+  const pwError = document.querySelector('#passwordErr');
+  const cpwError = document.querySelector('#confirmPasswordErr');
+
+  await flushPromises();
+  setValue(document.querySelector('#password') as HTMLInputElement, '123');
+  setValue(document.querySelector('#confirmPassword') as HTMLInputElement, '12');
+  await flushPromises();
+
+  expect(pwError?.textContent).toBeFalsy();
+  expect(cpwError?.textContent).toBeTruthy();
+  setValue(document.querySelector('#confirmPassword') as HTMLInputElement, '123');
+  await flushPromises();
+  expect(pwError?.textContent).toBeFalsy();
+  expect(cpwError?.textContent).toBeFalsy();
+});