Skip to content

Instantly share code, notes, and snippets.

@untitaker
Created September 29, 2017 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save untitaker/a41afabcdf608c68f86cdbe854f9b905 to your computer and use it in GitHub Desktop.
Save untitaker/a41afabcdf608c68f86cdbe854f9b905 to your computer and use it in GitHub Desktop.
require 'dry-struct'
module Types
include Dry::Types.module
end
class Bar < Dry::Struct
attribute :countries, Types::Strict::Array.member(
Types::Coercible::String
.constructor { |s| s.to_s.upcase }
.constrained(included_in: ["AT"])
)
end
Bar.new(countries: ["XX"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment