Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third party adapters #462

Merged
merged 40 commits into from
Oct 18, 2023
Merged

Third party adapters #462

merged 40 commits into from
Oct 18, 2023

Conversation

crutchcorn
Copy link
Member

@crutchcorn crutchcorn commented Sep 9, 2023

This PR implements an API akin to the following:

<form.Field validator={zodValidator} onChange={z.string().min(1, "Test")}>

And makes it a reality.

Closes #428

TODO

  • Split up zod adapter into dedicated package
    • Write integration tests
    • Write type tests
  • Write Yup adapter
  • Fix Vue adapter typings
  • Support async validation
    • Write integration tests for Yup/Zod validators
    • Write functionality itself
    • Add types
  • Add support for Form-level third-party adapters
    • Write integration test
    • Write types
    • Write functionality itself
  • Investigate/Fix legacy DTS generation from TSUp causing Vue failures
  • Docs
  • Examples

@crutchcorn
Copy link
Member Author

crutchcorn commented Sep 9, 2023

I'm reasonably sure there's a bug in the legacy setup of TSUp that's renaming this to this$1, even for DTS generation:

image

We'll need to resolve before merging this

@crutchcorn
Copy link
Member Author

The bug with TSUp is an underlying bug with rollup-plugin-dts: Swatinem/rollup-plugin-dts#279

@crutchcorn
Copy link
Member Author

Temporarily fixed the tsup/rollup-plugin-dts issue using PNPM's patch functionality. Long-term tracking of fix here:

Swatinem/rollup-plugin-dts#287

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 10, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
packages/form-core/src/utils.ts 89.13% <ø> (ø)
packages/react-form/src/createFormFactory.ts 100.00% <100.00%> (ø)
packages/react-form/src/formContext.ts 83.33% <ø> (ø)
packages/react-form/src/useForm.tsx 88.88% <100.00%> (ø)
packages/yup-form-adapter/src/tests/utils.ts 100.00% <100.00%> (ø)
packages/yup-form-adapter/src/validator.ts 100.00% <100.00%> (ø)
packages/zod-form-adapter/src/tests/utils.ts 100.00% <100.00%> (ø)
packages/zod-form-adapter/src/validator.ts 100.00% <100.00%> (ø)
packages/react-form/src/useField.tsx 85.71% <71.42%> (ø)
packages/form-core/src/FieldApi.ts 86.11% <86.36%> (-2.09%) ⬇️
... and 1 more

📢 Thoughts on this report? Let us know!.

@crutchcorn
Copy link
Member Author

@wobsoriano I believe I broke Vue's onChange value inferencing in this PR. Any chance you'd want to help me review the changes and figure out why that's the case? I'm admittedly a little stumped.

@wobsoriano
Copy link
Contributor

wobsoriano commented Sep 10, 2023

@crutchcorn Doing something like :onChange makes it a prop instead of an event in a Vue SFC, hence losing the types. What we're looking for is @change.

Changing the Vue example to @change fixes it:

Screenshot 2023-09-10 at 9 29 18 AM

SFC - @eventName
JS/JSX - onEventName (you can confirm this by looking at the test file)

So I don't think there's a problem with the typings. Just using the incorrect directive which should be v-on:change or @change in the example.

@crutchcorn crutchcorn changed the title [WIP] Third party adapters Third party adapters Oct 18, 2023
@crutchcorn crutchcorn marked this pull request as ready for review October 18, 2023 09:21
@crutchcorn crutchcorn merged commit 54652ee into main Oct 18, 2023
6 checks passed
@crutchcorn crutchcorn deleted the third-party-adapters branch October 18, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Support third-party validator libraries
3 participants