8000 Release v7.1.0 -- Standard Schema support Β· airjp73/rvf Β· GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

v7.1.0 -- Standard Schema support

Compare
Choose a tag to compare
@airjp73 airjp73 released this 13 Apr 19:43
· 35 commits to main since this release

Overview

The main addition for this release is support for Standard Schema. πŸŽ‰ We've also stabalized the useNativeValidityForForm api.

Standard Schema

It's now possible to directly pass zod, valibot, or any other Standard Schema compliant schema into the useForm hook or ValidatedForm component. To do this, you need to use the new schema option.

useForm({
  schema: z.object({ /* etc */ }),
})

Some other new features around this are:

Default values are now required

When using a Standard Schema schema, the defaultValues option is required. It remains optional if you're still using a validator.

Type inference for default values

Standard Schema allows schemas to define an input type for the schema. This is used to infer the type of default values, but it's still possible to widen this type if you need.

useForm({
  schema: z.object({
    myNumber: z.number(),
    myOtherNumber: z.number(),
  }),
  defaultValues: {
    // This still works!
    myNumber: null as null | number,
    // But this fails
    myOtherNumber: null,
  }
})

Zod and Valibot adapters deprecated

Zod and Valibot both support Standard Schema, so they are automatically supported by the schema prop.
Therefore, the withZod and withValibot adapters are now deprecated.

Future direction

I'm planning on eventually removing the validator prop in favor of schema. The official Yup adapter will eventually be reworked to wrap the Yup schema to make it Standard Schema compliant, rather than using a custom Validator object.

useNativeValidityForForm

This was an unstable API that's now been stabilized with this release. Read the docs here.


Auto release notes:

What's Changed

New Contributors

Full Changelog: v7...rvf-7.1.0

0