Comments (8)
@adamransom should this be a coercible string?
from dry-types.
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.
@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.
Yeah, definitely agree with that, and that's what I use as a workaround for now.
from dry-types.
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.
@adamransom good point. This also should be documented so that people don't expect any type of coercion.
from dry-types.
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 exceptParams::String
,Params::Array
andParams::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.
Using nominal type won't work, see #394 But I think strict types should work 🤔
from dry-types.
Related Issues (20)
- Type#fallback to mock previous implementation of Type#default HOT 10
- Constructor is not applied properly to the result of types Sum HOT 5
- Types::Params::Integer incorrect coercion for numeric values HOT 9
- Types::Params::*.optional not handling empty string HOT 4
- Anonymous Dry::Types based module cannot be extended HOT 4
- Params namespace disapearing HOT 9
- Params coercion for Array works in an unintuitive way HOT 1
- https://dry-rb.org/gems/dry-types/ not at latest version HOT 1
- [Security] Workflow ci.yml is using vulnerable action actions/checkout
- Compound Types with Examples HOT 1
- Dry::Container::Error: There is already an item registered with the key "nominal.string" on jruby-head HOT 4
- Future-proof local override for Types::Instance/Constructor classes that potentially collide with predicates
- Unexpected error raised from Sum type HOT 7
- Types::Coeercible::Integer, should this use Base 10? HOT 2
- Add Zeitwerk autoloader
- Using transform_keys breaks error handling
- Undefined method after upgrading dependencies. HOT 5
- Missing method implementation for `Enum.each_value` HOT 1
- Types.Constructor failing on Ruby 3.1 HOT 8
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 dry-types.