Sha256: 5cf90bf3023fdd05f9c6d195ce20c695950d65c5aba562bee5d62acd45a55128

Contents?: true

Size: 431 Bytes

Versions: 12

Compression:

Stored size: 431 Bytes

Contents

require 'dry-validation'

ast = [
  [
    :and,
    [
      [:key, [:age, [:predicate, [:key?, []]]]],
      [
        :and,
        [
          [:val, [:age, [:predicate, [:filled?, []]]]],
          [:val, [:age, [:predicate, [:gt?, [18]]]]]
        ]
      ]
    ]
  ]
]

compiler = Dry::Validation::RuleCompiler.new(Dry::Validation::Predicates)

rules = compiler.call(ast)

puts rules.inspect

puts rules.map(&:to_ary).inspect

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dry-validation-0.8.0 examples/rule_ast.rb
dry-validation-0.7.4 examples/rule_ast.rb
dry-validation-0.7.3 examples/rule_ast.rb
dry-validation-0.7.2 examples/rule_ast.rb
dry-validation-0.7.1 examples/rule_ast.rb
dry-validation-0.7.0 examples/rule_ast.rb
dry-validation-0.6.0 examples/rule_ast.rb
dry-validation-0.5.0 examples/rule_ast.rb
dry-validation-0.4.1 examples/rule_ast.rb
dry-validation-0.4.0 examples/rule_ast.rb
dry-validation-0.3.1 examples/rule_ast.rb
dry-validation-0.3.0 examples/rule_ast.rb