Comments (6)
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.
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)
- Not able to validate file uploads on the backend, even though it works on the frontend HOT 4
- Search fails to work HOT 1
- Timestamp regex doesn't support timezone other than Zulu HOT 1
- optional string field with string min/max options set wrong meta in veevalidate HOT 2
- How to conditionally require object with all its fields HOT 2
- `<select>` custom validation inside a `variant` schema HOT 4
- Function to support for json type HOT 2
- Number literal don't trigger variant validation HOT 7
- `_addIssue` blocks `every`, `some` & `check` actions rewrite due to a possible type issue HOT 2
- Email regex pattern does not allow all valid characters HOT 1
- Are there any similarities about zod `.superRefine`? HOT 1
- Error when building HOT 6
- How to access other field? HOT 2
- Allow null default value while enforcing required validation HOT 1
- Force typeing on object schema HOT 2
- Investigate memory, performance and bundle size impact when caching basic schema objects
- Conditionally validate HOT 2
- Not correct lang after set globally lang HOT 3
- `forward` not working when `transform` field throwing error
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.