Giter Club home page Giter Club logo

Comments (8)

solnic avatar solnic commented on July 18, 2024

@adamransom should this be a coercible string?

from dry-types.

adamransom avatar adamransom commented on July 18, 2024

Well, a string is a string I guess 😄 but I see the Params namespace as a place for all things you would usually expect to receive from HTTP parameters, String being one of them.

Though perhaps it is purely meant for coercion of things from params, in which case I suppose my work-around is what's intended?

But yeah, this issue is mainly just an ergonomics thing when using default: :params.

from dry-types.

solnic avatar solnic commented on July 18, 2024

@adamransom I think it should be added as Types::Params::String = Types::Nominal::String because param values are either string, array or hash and we don't want to accidentely coerce an array or a hash into a string. Does this make sense?

from dry-types.

adamransom avatar adamransom commented on July 18, 2024

Yeah, definitely agree with that, and that's what I use as a workaround for now.

from dry-types.

adamransom avatar adamransom commented on July 18, 2024

Though I suppose if we go down this route, we'd need to add ones for array and hash too, in order to be consistent with Params having everything we'd expect from HTTP params.

from dry-types.

solnic avatar solnic commented on July 18, 2024

@adamransom good point. This also should be documented so that people don't expect any type of coercion.

from dry-types.

adamransom avatar adamransom commented on July 18, 2024

Right, I guess the short description is:

Params contains every type you would expect to receive via HTTP params, coercing where it makes sense. Currently, everything is coerced except Params::String, Params::Array and Params::Hash.

Would we want to use Nominal or Strict as the types behind Params::String, Params::Array and Params::Hash though? The params type raise if they can't be coerced, so I'd imagine the expectation is to raise if the type isn't an array, for example.

from dry-types.

flash-gordon avatar flash-gordon commented on July 18, 2024

Using nominal type won't work, see #394 But I think strict types should work 🤔

from dry-types.

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.