dry-rb / dry-types

Flexible type system for Ruby with coercions and constraints
https://dry-rb.org/gems/dry-types
MIT License
861 stars 134 forks source link

Compound Types with Examples #429

Closed dsisnero closed 2 years ago

dsisnero commented 2 years ago

A type system should handle compound types like Quantity

Not sure how to make a length, weight, speed quantity with dry-types

Expected behavior

Dry::Types.load_extensions(:length) module Types include Dry.Types() end

class Equipment < Dry::Struct attribute :height, Types::Params::Length.inches() attribute :width, Types::Params::Length.inches()

end

radio = Equipment.new( height: "3", width: "4") puts radio.height => "3 inches"

flash-gordon commented 2 years ago

Pls forward questions or feature requests to our forum https://discourse.dry-rb.org/ (see CONTRIBUTING.md)