Giter Club home page Giter Club logo

Comments (4)

steida avatar steida commented on September 1, 2024 1

The performance of io-ts is a non-issue. And nobody is supposed to be forced to use it. It's about how types should be defined. io-ts first ensures we can have reliable runtime-type checking for people who needs it. With Either. Performance micro-optimization is orthogonal.

Note this can be easily ensured by io-ts. That's the point. Check https://www.youtube.com/watch?v=PLFl95c-IiU

Screenshot 2020-04-01 at 23 35 01

from faunadb-js.

hasparus avatar hasparus commented on September 1, 2024 1

I've been using io-ts for over a year, you don't have to advertise it to me :D

Note this can be easily ensured by io-ts.

This is checked by ts-json-validator at runtime.
"Can't enforce using type system" means "statically typechecked with type inferred from decoder".

All validating for refinement types must be done in userland at runtime unless there's been some recent development in RSC.

ts-json-validator currently supports every keyword, though not all of them contribute to the final derived type.

All good decoder libraries do two things.

  1. Validate
  2. Derive a static type

The table you attached is about deriving.

JSON Schema can do a lot, but it isn't turing complete.
There are certainly many use cases, which call for defining(refining) your types with predicates,
what I believe is impossible in ts-json-validator.

Check https://www.youtube.com/watch?v=PLFl95c-IiU

I watched this talk from NDC Sydney 2017. I really liked it :)
Did the 2019 version change a lot?

from faunadb-js.

steida avatar steida commented on September 1, 2024

Another example. Note serializeCookie signature requires FaunaSecret type. It can not accept a plain string. t.type({ secret: FaunaSecret }) ensures via its decode method that we really got secret.

Screenshot 2020-04-01 at 22 11 18

Maybe this stuff (Either and algebraic types composition and functional domain modeling) is new for you. It's much easier than it looks. And super useful. And available in TypeScript.

I highly recommend the first five minutes of this talk: https://www.youtube.com/watch?v=PLFl95c-IiU

from faunadb-js.

hasparus avatar hasparus commented on September 1, 2024

I'll just leave a note here.

I am aware that io-ts and fp-ts flavor functional API might not be for everyone.
I believe the idea of parsing data on application boundary to be sound regardless of preferred paradigm.

ts-json-validator is a nice alternative.

I'm using io-ts, but I wanted to present you with another option.

Pros

  1. It uses ajv, so it's crazy fast.
    image
  2. JSON Schema is pretty standard and the API might be more familar to some people.

Cons

There's a trade-off. It has 10x less stars and the API is subject to change.


The attached chart is from this benchmark.

from faunadb-js.

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.