Sha256: 965df8a0aa0c9eb9552af3e369ab286575b3d689a71bc6e3ddd4698086acf2e4

Contents?: true

Size: 409 Bytes

Versions: 4

Compression:

Stored size: 409 Bytes

Contents

# frozen_string_literal: true

require 'dry/logic'
require 'dry/logic/predicates'

include Dry::Logic

user_present = Rule::Predicate.build(Predicates[:key?]).curry(:user)

has_min_age = Operations::Key.new(Rule::Predicate.build(Predicates[:gt?]).curry(18), name: [:user, :age])

user_rule = user_present & has_min_age

puts user_rule.(user: { age: 19 }).success?

puts user_rule.(user: { age: 18 }).success?

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-logic-1.0.5 examples/basic.rb
dry-logic-1.0.4 examples/basic.rb
dry-logic-1.0.3 examples/basic.rb
dry-logic-1.0.2 examples/basic.rb