Comments (7)
You could use a little helper function:
import * as v from 'valibot';
function valibot<TSchema extends v.BaseSchema>(schema: TSchema): v.Output<TSchema> {
return (input: unknown) => v.parse(schema, input);
}
const query = await getValidatedQuery(event, valibot(YourSchema));
from valibot.
This is available in v0.31.0-rc.8
from valibot.
I understand, but as a library we can't provide adapters for every possible other library out there. It would make more sense to me if H3 would provide a Valibot adapter for their users.
from valibot.
The code excerpt above is not actually a provider for a specific library. It's a generic schema curry helper, and I believe it indeed deserves a method in Valibot.
import * as v from "valibot"
const schema = v.object({ ... })
const validate = v.parser(schema) // new method: convert a schema to an unary parser function
const input = validate(unsafeInput) // this logic is not related to h3, it's generally useful
The naming is a subject for discussion of course, but the actual idea quite makes sense.
from valibot.
Thank you for your feedback! Adding it might actually fix some problems with other libraries as well. If we find a good name, I might add such a utility.
from valibot.
Not sure if it is up to date, but there is also a dedicated community library: https://github.com/Intevel/h3-valibot
from valibot.
@fabian-hiller Thank you for your reply !
Yes this is what I have done for now but I figured it would be nice to have it built in Valibot.
Then developers don't need to make it themselves and it can be added nicely to the H3 doc later on.
from valibot.
Related Issues (20)
- Edge case bug with JSR version HOT 1
- Discord HOT 5
- [bug] Decimal schema is expecting null HOT 2
- [suggestion]: mimeType wildcard support HOT 2
- Missing TS warning in `pipe` method HOT 10
- Typescript: Incompatible Index Signatures HOT 1
- English translations are missing HOT 1
- Email validation not allowing specific letters (danish letters) HOT 3
- Valibot error on Vercel HOT 1
- omit doesn't work with objectWithRest HOT 9
- Minimum Viable Schema Protocol HOT 8
- Best way to validate optional ISO time HOT 2
- "Issues" field of SafeParseResult shows up in ts autocomplete after the type was narrowed with `.success` HOT 1
- set() expects Set HOT 2
- isoDatetime doesn't parse ISO datetime HOT 2
- First-person voice in the docs are a pain read HOT 5
- Add TypeScript types to documentation using TwoSlash HOT 1
- Attempted import error: 'getDotPath' is not exported fom 'validbot' (imported as 'o') HOT 3
- Typesafe introspection HOT 1
- Support for String normalization HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valibot.