Skip to content

Instantly share code, notes, and snippets.

@siassaj
Created August 28, 2017 04:35
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 siassaj/249c320a629b78e5671bc7e9b5a91326 to your computer and use it in GitHub Desktop.
Save siassaj/249c320a629b78e5671bc7e9b5a91326 to your computer and use it in GitHub Desktop.
class DeliveryDetails < Dry::Struct
constructor_type(:schema)
attribute :pickup_address, Address
attribute :dropoff_address, Address
attribute :dropoff_time, Types::Form::Time
attribute :reference, Types::String.optional
def dropoff_address_complete?
Dry::Validation.Schema do
required(:street).filled
required(:city).filled
required(:state).filled
required(:postcode).filled
required(:country).filled
end.(self.dropoff_address.to_hash).success?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment