Giter Club home page Giter Club logo

Comments (6)

fabian-hiller avatar fabian-hiller commented on May 20, 2024 2

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.

fabian-hiller avatar fabian-hiller commented on May 20, 2024 1

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.

IlyaSemenov avatar IlyaSemenov commented on May 20, 2024 1

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.

fabian-hiller avatar fabian-hiller commented on May 20, 2024 1

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.

fabian-hiller avatar fabian-hiller commented on May 20, 2024

Not sure if it is up to date, but there is also a dedicated community library: https://github.com/Intevel/h3-valibot

from valibot.

DylanThomasFr avatar DylanThomasFr commented on May 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.