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

feat: Add typia adapter #441

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Jun 6, 2024

fixes: #440

Hi! I made an adapter for typia!!

Changes

  • Added a new adapter file src/lib/adapters/typia.ts which defines typia and typiaClient adapter creation functions. These allow using typia for server-side and client-side form validation respectively.

  • Updated src/lib/adapters/adapters.ts to include 'typia' as a supported validation library type.

  • Added new test cases in src/tests/superValidate.test.ts to test form validation using the typia adapter. The tests cover validating fields like email, strings with no whitespace, arrays with min length, etc.

  • Modified vite.config.ts to include the @ryoppippi/unplugin-typia Vite plugin.

This allows users to leverage typia with superforms

Please let me know if you have any feedback or suggestions to improve the typia integration.

This commit includes the following changes:
- Typia added to devDependencies in package.json
- New npm script 'prepare' added for Typia patching
- New registry '@jsr:registry' added in .npmrc for jsr
- UnpluginTypia included in vite.config.ts plugins
Copy link

vercel bot commented Jun 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
superforms ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 9, 2024 2:28pm

This commit introduces a new validation adapter for the 'typia' library.
The adapter is implemented in 'src/lib/adapters/typia.ts'. It includes
functions for both server-side and client-side validation. The
implementation also includes a test case in
'src/tests/superValidate.test.ts' to ensure the adapter works as
expected.
This commit introduces 'typia' as an optional dependency in the
package.json file. This is to ensure that the project can optionally
utilize the features provided by 'typia'.
This commit updates the version of @ryoppippi/unplugin-typia from v0.2.2
to v0.3.3 in both package.json and pnpm-lock.yaml. It also adds a new
field "packageManager" in package.json with the value "[email protected]+sha256.
30a1801ac4e723779efed13a21f4c39f9eb6c9fbb4ced101bce06b422593d7c9".
The @ryoppippi/unplugin-typia dependency has been upgraded from
v0.3.3 to v0.3.7. This includes updates in the package.json and
pnpm-lock.yaml files. The upgrade may include bug fixes,
performance improvements, and new features.
@ciscoheat
Copy link
Owner

Hi, as I mentioned earlier, the extra configuration (vite.config.ts for example, with the introduction of an experimental library) makes it hard to directly integrate it into the project. Do you think you can have this adapter as a separate npm library?

@ryoppippi
Copy link
Contributor Author

ryoppippi commented Jun 12, 2024

How about writing how to use it in the Documentation and making the users aware of it, so that it is not a problem?
I think my vite plugin and superforms works fine.

@ciscoheat
Copy link
Owner

It's more work than I have time for at the moment, but you can make a PR to the documentation to speed things up: https://github.com/ciscoheat/superforms-web

@ryoppippi
Copy link
Contributor Author

NIce Thanks!

@ciscoheat ciscoheat added this to the v3 milestone Aug 10, 2024
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.

typia support
2 participants