Giter Club home page Giter Club logo

Comments (12)

gyzerok avatar gyzerok commented on May 12, 2024

Sorry for quite a long read. This is quite rough summary of my thoughts. Feel free to suggest/disagree/correct.

from io-ts.

gcanti avatar gcanti commented on May 12, 2024

@gyzerok first of all thanks for the great write up

Validation vs Decoding

decode is nice. Honestly I have no strong opinion on this, I'm fine with both validate and decode.

Either vs Promise

On the contrary here I have a clear preference: I need a synchronous API. There are other use cases for IO validation I'm interested in other than endpoints, for example validating forms or (sync) APIs of "untrusted" libraries, or even for something like prop types.

Make reporting nicer and part of core

This is the reason why reporters are not part of the core :)

I learned from the past (issues on tcomb and flow-io) that how users want errors being displayed is somehow a matter of taste, no matter how good you define the default reporter. For example some.nested.[0].field is expected to be string, but is given number: 123 is nice, but this would be even nicer for some users (a kind of super reporter!) gcanti/flow-io#14 (comment).

Validator could be chainable

Either is already chainable (is a fantasy-land compliant monad instance)

const DateFromString = new t.Type<Date>(
  'Date',
  (v, c) => t.string.validate(v, c).chain(s => {
    const d = new Date(v)
    return isNaN(d.getTime()) ? t.failure<Date>(v, c) : t.success(d)
  })
)

Overall for now I consider io-ts a low level library you can build upon and/or customize in userland, but I'm open to discussions.

from io-ts.

gcanti avatar gcanti commented on May 12, 2024

FYI just published a trial version on the next channel (is not an official release, just a way to try the new version and iron out possible bugs)

npm install io-ts@next

from io-ts.

gyzerok avatar gyzerok commented on May 12, 2024

@gcanti thanks! And sorry for silence, just have not had enough time to respond yet.

from io-ts.

gcanti avatar gcanti commented on May 12, 2024

FYI just released the new version ([email protected])

EDIT: change log https://github.com/gcanti/io-ts/releases/tag/0.1.1

from io-ts.

gyzerok avatar gyzerok commented on May 12, 2024

I guess your point is pretty clear, so let's close issue for now and come back if there are more things to discuss in the future

from io-ts.

gcanti avatar gcanti commented on May 12, 2024

Hi @gyzerok, in order to apply some of my last libraries to real world problems, I'm working on a porting of Elm to TypeScript featuring

  • fp-ts as functional library
  • monocle-ts for functional optics
  • io-ts for decoders
  • rxjs 5 as reactive engine
  • React as (pluggable) vdom library

As an Elm user I'd love to hear your feedback

from io-ts.

gyzerok avatar gyzerok commented on May 12, 2024

@gcanti thanks for mentioning me! I will definitely take a look when have some time. You also might want to consider redux-loop library and my work towards new API for it. Maybe we can achieve some kind of synergy between efforts :)

P.S.: I guess that io-ts would be a bit nicer to have Decoder instead of Validator.

from io-ts.

OliverJAsh avatar OliverJAsh commented on May 12, 2024

@gyzerok

Make reporting nicer and part of core

I feel you on this one. I started a repository to share the reporter(s) I've been using: https://github.com/OliverJAsh/io-ts-reporters

I'm currently aiming to have some parity with the error messages returned by Elm decoders: gillchristian/io-ts-reporters#3

I would love your help on this.

from io-ts.

gyzerok avatar gyzerok commented on May 12, 2024

@OliverJAsh yeah, I implemented something like this.

Maybe it would make sense to run some poll around that in Twitter @gcanti? I hardly can imagine why would people need reporting not in that way.

from io-ts.

gcanti avatar gcanti commented on May 12, 2024

Make reporting nicer and part of core

Does "core" mean the index.ts module? What do you propose? Or are you talking about adding @OliverJAsh 's reporter (or/and other variations) to the default ones? If that's the case, I'm fine with that.

from io-ts.

OliverJAsh avatar OliverJAsh commented on May 12, 2024

I don't mind where the reporters live—here or elsewhere—but it would be good to combine efforts.

from io-ts.

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.