Skip to content

Releases: logaretm/vee-validate

v4.10.0

22 Jun 23:44
Compare
Choose a tag to compare

💣 Breaking Change

Disabled syncVModel by default #4283 (7ce9d67)

A lot of issues created because of this and valid issues and concerns by the community caused by useField auto model tracking causing unexpected behavior for a lot of people. The feature has been disabled by default starting from v4.10.0.

If you relied on useField doing auto modelValue and update:modelValue emitting then you need to turn it on by passing true to syncVModel.

const { ... } = useField('name', undefined, {
 syncVModel: true,
});

Check the discussion in #4283

This makes sense, because it being opt-in makes it less dangerous to cause unexpected behavior.

useForm#values is now readonly #4282 (05d957e)

the values object returned from useForm should have never been treated as mutable and the docs mentioned that a few times and didn't encourage it.

In this release, we mark it as readonly to make it clear to everyone that it should not be mutated directly. The main reason for this design choice is we need to be able to infer the user intent with those mutations. For example, if you clear an array, did you mean to reset the field or did you mean to change its value and trigger a validation?

Being able to infer the user intent is paramount for vee-validate to be able to handle such behaviors correctly, it has always been the case here, and marking it as readonly is just a hint that should've been there from the start.

This should not affect a lot of users.

💅 DX enhancements

  • Allow custom models for defineComponentBinds (bfd6b00)
  • handleBlur can be configured to run validations (d4fafc9)
  • useField#syncVModel also accepts the model prop name (3e4a7c1)
  • Allow multiple messages to be returned in a validator function #4322 #4318 (2cf0eec)

🐛 Bug Fixes

👕 TypeScript

vee-validate v4.10.0 requires [email protected] as it uses many of the newly introduced types to replace its own version of them, this should not affect your experience however it may produce type errors if you relied on some of these internal types. Like MaybeRefOrLazy replaced with MaybeRefOrGetter.

v4.9.6

31 May 20:48
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Field's handleBlur should respect validateOnBlur config #4285 (6e074f7)
  • Correctly merge non-plain objects in form's setValues #4287 (#4289) thanks to @VladStepanov

👕 TypeScript

  • Improve Field binding types (#4291) thanks to @FedorSherbakov
  • export SetFieldValueOptions interface #4290 (b138282)

v4.9.5

21 May 23:03
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Allow labels to be localized with dictionary names prop #4268 (16580b4)
  • setFieldError sets meta.valid correctly #4274 (7356c10)

🆕 New features

  • Exposed componentField on Field slot props to make it easier to integrate with components (#4270) thanks to @FedorSherbakov

v4.9.4

17 May 22:57
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Types: Exclude undefined and null from initial values resolution #4139 (f4ea2c0)
  • Bundle: Components were not being tree-shaken correctly (#4266) thanks to @ydcjeff
  • devtool: add compatibility for UTF character (#4265) thanks to @linghaoSu

v4.9.3

11 May 01:14
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Run validation on value change #4251 (09d5596)
  • Hoist nested errors to the nearest parent state #4063 (#4259)

🆕 New features

  • Added isValidating on the form context (#4244) thanks to @jusheng27

v4.9.2

09 May 22:22
Compare
Choose a tag to compare

🐛 Bug fixes

  • Hiding array fields with v-if did not remove the last item correctly #4115 (fe322a0)
  • Removing some items caused other items to lose value in a field array loop #4239 (31090e0)
  • Validations run for unmounted fields when keep-values is enabled #4247 (9046308)

v4.9.1

08 May 08:19
Compare
Choose a tag to compare

🐛 Bug fixes

  • Added type-fest to dependencies on the core package #4242 (681bbab)
  • Hide nested value write warning if the value isn't an object (18f3c1c)
  • Fix Type errors when using v-bind="field" on a textarea element #4031 (ce2f539)

v4.9.0

07 May 16:55
Compare
Choose a tag to compare

This release required a lot of internal changes to how vee-validate tracks fields to have better DX down the line. There shouldn't be any breaking changes to your apps, as all the tests are passing with these changes. But some behaviors may differ if you were using some unintentional bugs as features.

The main change is vee-validate shifting from thinking about fields as unique field instances to treating them as outlets for path values. The outcome is the same in most cases but allows for more ways for vee-validate to define fields.

💣 Possible breaking changes

  • setValues was deleting the other values not specified, now it only sets the fields partially as provided without deleting any values. #4231 (298577b)
  • If you were using a field's meta with group fields (checkboxes/radio), each field had its own meta, with this release all those fields will have the exact same meta values.
  • Validations are now run only when a value setter has been triggered, this should not break anything but if you were using nested values as field values you will get a warning and which alternative to use.

🆕 New Features

Component Binds

useForm now exposes a new helper defineComponentBinds which allows you to create bindable objects for your components.

This is meant as replacement for useFieldModel and should replace using useField as a model. useField is still the best way to build input fields components, but if you don't want to wrap your fields with useField especially with 3rd party UI component libraries then defineComponentBinds is the way to go.

This is an example with Vuetify:

<script>
const schema = toTypedSchema(yup.object({
  email: yup.string().email().required().label('E-mail'),
  password: yup.string().min(6).required(),
}));

const { defineComponentBinds } = useForm({
  validationSchema: schema
});

const email = defineComponentBinds('email', {
 // maps error messages to Vuetify
  mapProps: (state) => ({ 'error-messages': state.errors  })
});
const password = defineComponentBinds('password');
</script>

<template>
  <v-text-field
    v-bind="email"
    label="email"
    type="email"
  />

  <v-text-field
    v-bind="password"
    label="password"
    type="password"
   />
</template>

Input Binds

Another helper exposed by useForm is defineInputBinds which allows you to create bindable objects for your HTML elements.

<script>
const schema = toTypedSchema(yup.object({
  email: yup.string().email().required().label('E-mail'),
  password: yup.string().min(6).required(),
}));

const { defineInputBinds } = useForm({
  validationSchema: schema
});

const email = defineInputBinds('email', {
 // Adds attributes to the element, like classes, aria-attrs, etc...
  mapAttrs: (state) => ({ 'aria-invalid': state.valid ? 'false' : 'true'  })
});
const password = defineInputBinds('password');
</script>

<template>
  <input
    v-bind="email"
    label="email"
    type="email"
  />

  <input
    v-bind="password"
    label="password"
    type="password"
   />
</template>

📚 Docs update WIP

The docs will be updated throughout the week to include a new guide for the composition API and the recommended ways to set up fields depending on the different requirements.

Some of the recently added features will be missing until the re-write is complete.

🐛 Bug Fixes

  • Removing a field from useFieldArray should not trigger validation for unchanged fields #4017 (7554d4a)
  • fix: handle mimes with plus symbol #4230 (f5b3482)
  • fix: support surrogate pairs (#4229) thanks to @naokihaba
  • fix: Zod transforms not reflecting in output types correctly #4227 (93228b7)
  • fix: corrected slot prop types for field component #4223 (b2c4967)

v4.8.6

17 Apr 02:14
Compare
Choose a tag to compare

🆕 Nuxt Module

Published the offical vee-validate nuxt module, to install the module:

npm i @vee-validate/nuxt

then you can add it to nuxt.config.ts:

export default defineNuxtConfig({
  // ...
  modules: [
    //...
    '@vee-validate/nuxt',
  ],
});

check the documentation for more information and how to configure it.

v4.8.5

15 Apr 03:26
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Fixed zod unions errors not mapping to field errors #4204 (9048a23)
  • Fixed falsy model initial value not overriding form value #4200 (07418b9)