Skip to content

Commit

Permalink
dry-validation now raises if the argument isn't a Hash. Fix 1/n
Browse files Browse the repository at this point in the history
  • Loading branch information
mereghost committed Jan 7, 2025
1 parent 3ea1ad6 commit 85aba0d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/types/patterns/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
module Types
module Patterns
Collection = Data.define(:patterns) do
extend Dry::Monads[:result]
private_class_method :new

def self.build(patterns:, contract: CollectionContract.new)
contract.call(patterns).to_monad.fmap { |success| new(success.to_h) }
rescue ArgumentError => e
Failure(e)
end

def initialize(patterns:)
Expand Down

0 comments on commit 85aba0d

Please sign in to comment.