Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: logaretm/vee-validate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.8.6
Choose a base ref
...
head repository: logaretm/vee-validate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.9.0
Choose a head ref

Commits on Apr 18, 2023

  1. chore: upgrade dependencies

    logaretm committed Apr 18, 2023
    Copy the full SHA
    29c9cc0 View commit details

Commits on Apr 20, 2023

  1. Copy the full SHA
    b3fdd4f View commit details
  2. fix: export path type

    logaretm committed Apr 20, 2023
    Copy the full SHA
    21398d7 View commit details
  3. Copy the full SHA
    7f4f4ff View commit details
  4. fix: type useFieldModel

    logaretm committed Apr 20, 2023
    Copy the full SHA
    9726e74 View commit details
  5. fix: shameful casting

    logaretm committed Apr 20, 2023
    Copy the full SHA
    9296965 View commit details
  6. chore: changeset

    logaretm committed Apr 20, 2023
    Copy the full SHA
    41b5d39 View commit details
  7. Copy the full SHA
    b2c4967 View commit details

Commits on Apr 21, 2023

  1. fix: type fixes

    logaretm committed Apr 21, 2023
    Copy the full SHA
    d4e4d94 View commit details

Commits on Apr 22, 2023

  1. chore: upgrade deps

    logaretm committed Apr 22, 2023
    Copy the full SHA
    e324dcb View commit details
  2. Copy the full SHA
    2d48d12 View commit details

Commits on Apr 23, 2023

  1. Copy the full SHA
    93228b7 View commit details

Commits on Apr 30, 2023

  1. docs: head seo url

    logaretm committed Apr 30, 2023
    Copy the full SHA
    5d4040d View commit details
  2. Copy the full SHA
    b6dd1fc View commit details
  3. chore: fix externals

    logaretm committed Apr 30, 2023
    Copy the full SHA
    29b835f View commit details

Commits on May 6, 2023

  1. Copy the full SHA
    9cf3ec6 View commit details
  2. chore: upgrade dependencies

    logaretm committed May 6, 2023
    Copy the full SHA
    101fd6e View commit details

Commits on May 7, 2023

  1. Copy the full SHA
    9540908 View commit details
  2. Copy the full SHA
    298577b View commit details
  3. Copy the full SHA
    f5b3482 View commit details
  4. Copy the full SHA
    b85f496 View commit details
  5. Copy the full SHA
    9b0f74a View commit details
  6. Copy the full SHA
    c2e1e0f View commit details
  7. Copy the full SHA
    be64c38 View commit details
  8. Copy the full SHA
    7554d4a View commit details
  9. chore: bump release

    logaretm committed May 7, 2023
    Copy the full SHA
    1d02edf View commit details
  10. fix: pnpm lock

    logaretm committed May 7, 2023
    Copy the full SHA
    ab9610f View commit details
Showing with 3,576 additions and 1,818 deletions.
  1. +3 −0 .circleci/config.yml
  2. +1 −0 README.md
  3. +6 −1 docs/src/components/SiteHead.astro
  4. +2 −2 docs/src/pages/api/use-form.mdx
  5. +22 −21 package.json
  6. +2 −0 packages/i18n/CHANGELOG.md
  7. +1 −1 packages/i18n/package.json
  8. +10 −0 packages/nuxt/CHANGELOG.md
  9. +2 −2 packages/nuxt/package.json
  10. +11 −0 packages/rules/CHANGELOG.md
  11. +2 −2 packages/rules/package.json
  12. +1 −1 packages/rules/src/max.ts
  13. +14 −3 packages/rules/src/mimes.ts
  14. +1 −1 packages/rules/src/min.ts
  15. +2 −0 packages/rules/tests/max.spec.ts
  16. +6 −0 packages/rules/tests/mimes.spec.ts
  17. +2 −0 packages/rules/tests/min.spec.ts
  18. +12 −0 packages/vee-validate/CHANGELOG.md
  19. +1 −0 packages/vee-validate/README.md
  20. +1 −1 packages/vee-validate/package.json
  21. +7 −5 packages/vee-validate/src/Field.ts
  22. +7 −14 packages/vee-validate/src/Form.ts
  23. +129 −98 packages/vee-validate/src/devtools.ts
  24. +6 −0 packages/vee-validate/src/index.ts
  25. +0 −264 packages/vee-validate/src/types.ts
  26. +24 −0 packages/vee-validate/src/types/common.ts
  27. +17 −0 packages/vee-validate/src/types/devtools.ts
  28. +336 −0 packages/vee-validate/src/types/forms.ts
  29. +4 −0 packages/vee-validate/src/types/index.ts
  30. +201 −0 packages/vee-validate/src/types/paths.ts
  31. +126 −101 packages/vee-validate/src/useField.ts
  32. +29 −18 packages/vee-validate/src/useFieldArray.ts
  33. +59 −38 packages/vee-validate/src/useFieldState.ts
  34. +440 −442 packages/vee-validate/src/useForm.ts
  35. +6 −15 packages/vee-validate/src/useIsFieldDirty.ts
  36. +6 −14 packages/vee-validate/src/useIsFieldTouched.ts
  37. +6 −14 packages/vee-validate/src/useIsFieldValid.ts
  38. +13 −13 packages/vee-validate/src/useValidateField.ts
  39. +0 −14 packages/vee-validate/src/utils/assertions.ts
  40. +31 −15 packages/vee-validate/src/utils/common.ts
  41. +12 −11 packages/vee-validate/src/validate.ts
  42. +85 −1 packages/vee-validate/tests/FieldArray.spec.ts
  43. +4 −2 packages/vee-validate/tests/helpers/ModelComp.ts
  44. +10 −18 packages/vee-validate/tests/useField.spec.ts
  45. +291 −1 packages/vee-validate/tests/useFieldArray.spec.ts
  46. +273 −1 packages/vee-validate/tests/useForm.spec.ts
  47. +10 −0 packages/yup/CHANGELOG.md
  48. +4 −4 packages/yup/package.json
  49. +10 −0 packages/zod/CHANGELOG.md
  50. +3 −3 packages/zod/package.json
  51. +1,324 −676 pnpm-lock.yaml
  52. +1 −1 scripts/config.mjs
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@ jobs:
- run:
name: Build
command: pnpm build
- run:
name: Type check
command: pnpm typecheck
- run:
name: Generate Coverage
command: pnpm cover
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -168,6 +168,7 @@ You are welcome to contribute to this project, but before you do, please make su

- Inspired by Laravel's [validation syntax](https://laravel.com/docs/5.4/validation)
- v4 API Inspired by [Formik's](https://github.com/formium/formik)
- Nested path types by [react-hook-form](https://github.com/react-hook-form/react-hook-form)
- Logo by [Baianat](https://github.com/baianat)

## Emeriti
7 changes: 6 additions & 1 deletion docs/src/components/SiteHead.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { generateMetaTags, generateSocialImage } from '@/utils/seo';
import { generateLinks, generateMetaTags, generateSocialImage } from '@/utils/seo';
import config from '@/config';
const { frontmatter } = Astro.props;
@@ -19,6 +19,10 @@ const metaTags = generateMetaTags({
url: `${config.appURL}${path}`,
image,
});
const links = generateLinks({
url: `${config.appURL}${path}`,
});
---

<head>
@@ -27,6 +31,7 @@ const metaTags = generateMetaTags({
<link rel="icon" type="image/x-icon" href="/v4/img/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
{metaTags.map(t => <meta content={t.content} name={t.name} property={t.property} />)}
{links.map(t => <link href={t.href} rel={t.rel} />)}
<script is:inline src="/v4/loadTheme.js"></script>
<script src="https://cdn.usefathom.com/script.js" data-site="OYTLUCCD" defer></script>
</head>
4 changes: 2 additions & 2 deletions docs/src/pages/api/use-form.mdx
Original file line number Diff line number Diff line change
@@ -171,11 +171,11 @@ interface FormMeta<TValues extends Record<string, any>> {
initialValues?: TValues;
}

type InvalidSubmissionHandler<TValues extends GenericFormValues = GenericFormValues> = (
type InvalidSubmissionHandler<TValues extends GenericObject = GenericObject> = (
ctx: InvalidSubmissionContext<TValues>
) => void;

type HandleSubmitFactory<TValues extends GenericFormValues> = <TReturn = unknown>(
type HandleSubmitFactory<TValues extends GenericObject> = <TReturn = unknown>(
cb: SubmissionHandler<TValues, TReturn>,
onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>
) => (e?: Event) => Promise<TReturn | undefined>;
43 changes: 22 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -13,54 +13,55 @@
"format": "prettier \"./**/*.ts\" --write",
"build": "node scripts/build.mjs",
"cover": "vitest run --coverage",
"postversion": "npm run build",
"docs:dev": "cd ./docs && npm run dev && cd -",
"postversion": "pnpm build",
"typecheck": "pnpm tsc --noEmit --project ./tsconfig.json --skipLibCheck",
"docs:dev": "cd ./docs && pnpm dev && cd -",
"postinstall": "husky install",
"release": "./scripts/release.sh"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@commitlint/cli": "^17.6.3",
"@commitlint/config-conventional": "^17.6.3",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-typescript": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@vitest/coverage-c8": "^0.29.7",
"@rollup/plugin-typescript": "^11.1.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@vitest/coverage-c8": "^0.31.0",
"@vue/devtools-api": "^6.5.0",
"chalk": "^5.2.0",
"eslint": "^8.36.0",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"filesize": "^10.0.6",
"filesize": "^10.0.7",
"flush-promises": "^1.0.2",
"fs-extra": "^11.1.0",
"fs-extra": "^11.1.1",
"gzip-size": "^7.0.0",
"husky": "^8.0.3",
"jsdom": "^21.1.1",
"jsdom": "^22.0.0",
"klona": "^2.0.6",
"lint-staged": "^13.2.0",
"prettier": "^2.8.4",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"prettier-plugin-astro": "^0.8.0",
"raf-stub": "^3.0.0",
"rollup": "^3.20.0",
"rollup": "^3.21.5",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"terser": "^5.16.6",
"terser": "^5.17.1",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"type-fest": "^3.6.1",
"typescript": "4.9.5",
"vitest": "^0.29.7",
"type-fest": "^3.10.0",
"typescript": "5.0.4",
"vitest": "^0.31.0",
"vue": "^3.2.47",
"yup": "^1.0.2"
"yup": "^1.1.1"
},
"peerDependencies": {
"vue": "^3.2.0"
2 changes: 2 additions & 0 deletions packages/i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.9.0

## 4.8.6

### Patch Changes
2 changes: 1 addition & 1 deletion packages/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vee-validate/i18n",
"version": "4.8.6",
"version": "4.9.0",
"description": "Localization module for VeeValidate",
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
"homepage": "https://vee-validate.logaretm.com/v4/guide/i18n",
10 changes: 10 additions & 0 deletions packages/nuxt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @vee-validate/nuxt

## 4.9.0

### Patch Changes

- Updated dependencies [7554d4a6]
- Updated dependencies [41b5d39b]
- Updated dependencies [95409080]
- Updated dependencies [298577b7]
- vee-validate@4.9.0

## 4.8.6

### Patch Changes
4 changes: 2 additions & 2 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vee-validate/nuxt",
"version": "4.8.6",
"version": "4.9.0",
"description": "Official vee-validate nuxt module",
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
"license": "MIT",
@@ -37,7 +37,7 @@
"dependencies": {
"@nuxt/kit": "^3.4.0",
"local-pkg": "^0.4.3",
"vee-validate": "^4.8.6"
"vee-validate": "^4.9.0"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
11 changes: 11 additions & 0 deletions packages/rules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 4.9.0

### Patch Changes

- f5b34823: handle mimes with plus signs
- Updated dependencies [7554d4a6]
- Updated dependencies [41b5d39b]
- Updated dependencies [95409080]
- Updated dependencies [298577b7]
- vee-validate@4.9.0

## 4.8.6

### Patch Changes
4 changes: 2 additions & 2 deletions packages/rules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vee-validate/rules",
"version": "4.8.6",
"version": "4.9.0",
"description": "Form Validation for Vue.js",
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
"license": "MIT",
@@ -28,6 +28,6 @@
"dist/*.d.ts"
],
"dependencies": {
"vee-validate": "^4.8.6"
"vee-validate": "^4.9.0"
}
}
2 changes: 1 addition & 1 deletion packages/rules/src/max.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const maxLengthValidator = (value: unknown, params: [string | number] | { length
return value.every(val => maxLengthValidator(val, { length }));
}

return String(value).length <= Number(length);
return [...String(value)].length <= Number(length);
};

export default maxLengthValidator;
17 changes: 14 additions & 3 deletions packages/rules/src/mimes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { isEmpty } from './utils';

const ADDED_MIME_RE = /\+(.+)?/;

function buildRegExp(mime: string) {
let strPattern = mime;
if (ADDED_MIME_RE.test(mime)) {
strPattern = mime.replace(ADDED_MIME_RE, '(\\+$1)?');
}

return new RegExp(strPattern.replace('*', '.+'), 'i');
}

const mimesValidator = (files: unknown, mimes: string[]) => {
if (isEmpty(files)) {
return true;
@@ -9,12 +20,12 @@ const mimesValidator = (files: unknown, mimes: string[]) => {
mimes = [];
}

const regex = new RegExp(`${mimes.join('|').replace('*', '.+')}$`, 'i');
const patterns = mimes.map(buildRegExp);
if (Array.isArray(files)) {
return files.every(file => regex.test((file as File).type));
return files.every(file => patterns.some(p => p.test((file as File).type)));
}

return regex.test((files as File).type);
return patterns.some(p => p.test((files as File).type));
};

export default mimesValidator;
2 changes: 1 addition & 1 deletion packages/rules/src/min.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const minValidator = (value: unknown, params: [string | number] | { length: stri
return value.every(val => minValidator(val, { length }));
}

return String(value).length >= Number(length);
return [...String(value)].length >= Number(length);
};

export default minValidator;
2 changes: 2 additions & 0 deletions packages/rules/tests/max.spec.ts
Original file line number Diff line number Diff line change
@@ -11,10 +11,12 @@ test('validates maximum number of characters in a string', () => {
expect(validate(null, params)).toBe(true);
expect(validate('', params)).toBe(true);
expect(validate([1, 2], params)).toBe(true);
expect(validate('𩸽寿司', params)).toBe(true);

// invalid
expect(validate('abcde', params)).toBe(false);
expect(validate('null', params)).toBe(false);
expect(validate('undefined', params)).toBe(false);
expect(validate(['1234'], params)).toBe(false);
expect(validate('𩸽寿司の', params)).toBe(false);
});
6 changes: 6 additions & 0 deletions packages/rules/tests/mimes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import validate from '../src/mimes';
import helpers from './helpers';

test('validates mime types', () => {
const params = ['image/*', 'text/plain'];

@@ -16,3 +17,8 @@ test('validates mime types', () => {

expect(validate(helpers.file('file.pdf', 'application/pdf'), params)).toBe(false);
});

test('mimes with regex characters', () => {
expect(validate(helpers.file('file.svg', 'image/svg'), ['image/svg+xml'])).toBe(true);
expect(validate(helpers.file('file.svg', 'image/xml'), ['image/svg+xml'])).toBe(false);
});
2 changes: 2 additions & 0 deletions packages/rules/tests/min.spec.ts
Original file line number Diff line number Diff line change
@@ -13,9 +13,11 @@ test('validates minimum number of characters in a string', () => {
expect(validate(null, params)).toBe(true);
expect(validate('', params)).toBe(true);
expect(validate([], params)).toBe(true);
expect(validate('𩸽寿司', params)).toBe(true);

// invalid
expect(validate(1, params)).toBe(false);
expect(validate(12, params)).toBe(false);
expect(validate([1], params)).toBe(false);
expect(validate('𩸽', params)).toBe(false);
});
12 changes: 12 additions & 0 deletions packages/vee-validate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## 4.9.0

### Minor Changes

- 41b5d39b: Implemented path types into various form API functions
- 95409080: Added component and input binds helpers

### Patch Changes

- 7554d4a6: fix field array triggering validation when an item is removed
- 298577b7: setValues does not delete unspecified fields values

## 4.8.6

### Patch Changes
1 change: 1 addition & 0 deletions packages/vee-validate/README.md
Original file line number Diff line number Diff line change
@@ -168,6 +168,7 @@ You are welcome to contribute to this project, but before you do, please make su

- Inspired by Laravel's [validation syntax](https://laravel.com/docs/5.4/validation)
- v4 API Inspired by [Formik's](https://github.com/formium/formik)
- Nested path types by [react-hook-form](https://github.com/react-hook-form/react-hook-form)
- Logo by [Baianat](https://github.com/baianat)

## Emeriti
2 changes: 1 addition & 1 deletion packages/vee-validate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vee-validate",
"version": "4.8.6",
"version": "4.9.0",
"description": "Form Validation for Vue.js",
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
"license": "MIT",
12 changes: 7 additions & 5 deletions packages/vee-validate/src/Field.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { getConfig } from './config';
import { RuleExpression, useField } from './useField';
import { normalizeChildren, hasCheckedAttr, shouldHaveValueBinding, isPropPresent, normalizeEventValue } from './utils';
import { IS_ABSENT } from './symbols';
import { FieldMeta } from './types';
import { FieldMeta, InputType } from './types';
import { FieldContext } from '.';

interface ValidationTriggersProps {
@@ -14,11 +14,13 @@ interface ValidationTriggersProps {
validateOnModelUpdate: boolean;
}

type EventHandlerBinding<T> = T | T[];

interface FieldBindingObject<TValue = unknown> {
name: string;
onBlur: (e: Event) => unknown;
onInput: (e: Event) => unknown;
onChange: (e: Event) => unknown;
onBlur: EventHandlerBinding<(e: Event) => unknown>;
onInput: EventHandlerBinding<(e: Event) => unknown>;
onChange: EventHandlerBinding<(e: Event) => unknown>;
'onUpdate:modelValue'?: ((e: TValue) => unknown) | undefined;
value?: unknown;
checked?: boolean;
@@ -130,7 +132,7 @@ const FieldImpl = defineComponent({
validateOnMount: props.validateOnMount,
bails: props.bails,
standalone: props.standalone,
type: ctx.attrs.type as string,
type: ctx.attrs.type as InputType,
initialValue: resolveInitialValue(props, ctx),
// Only for checkboxes and radio buttons
checkedValue: ctx.attrs.value,
Loading