Skip to content

v0.43.0

Compare
Choose a tag to compare
@github-actions github-actions released this 21 Feb 11:15
· 84 commits to main since this release

Version 0.43.0 - 2/21/25, 11:14 AM

PRs

  • Allow returning anything in a validator (#1104) (d8ed149) by Corbin Crutchley

The Main Showcase

This PR allows you to return non-string values from validators:

<form.Field name="password" validators={{onChange: () => ({hasUppercase: false, hasLowercase: true}) }} />

In addition, it also enforces type safety on the returned value on both errorMap and the errors array:

const form = new FormApi({
  defaultValues: {
    name: 'test',
  },
} as const)

const field = new FieldApi({
  form,
  name: 'name',
  validators: {
    onChange: () => {
      return 123 as const
    },
  },
})

assertType<123 | undefined>(field.state.meta.errorMap.onChange)

assertType<Array<123 | undefined>>(field.state.meta.errors)

Breaking Changes

  • Removes all validatorAdapters (packages, code, and props alike)
  • When using Standard Schema validators:
    • form.errors is now Record<string, StandardSchemaV1Issue[]>
    • field.errors is now StandardSchemaV1Issue[] (flattened, unless you pass disableErrorFlat in form.Field)
  • Vue 3.4 is the new minimum version
  • Vue JSX usage no longer works

Migration Guide

If you're using Yup today, you'll either need to wait for this community PR to be merged or replace Yup with another schema library.

  • If using schema validation:
    • Remove all validatorAdapter properties
    • Uninstall @tanstack/yup-form-adapter, @tanstack/valibot-form-adapter, and @tanstack/zod-form-adapter
    • Migrate all validation errors on a field away from .map(str => <p>{str}</p>) and towards .map(issue => <p>{issue.messaeg}</p>)
    • Migrate all validation errors on form away from .map(str => <p>{str}</p>) and towards .map(issueObj => <p>{issueObj.issues[0].message}</p>)
  • (If Vue): Migrate form components to use SFCs

Other Changes

  • Vue SFC Works as-intended
  • TanStack Start Adapter has been updated to new APIs

Packages