Sha256: 997ea2d09207d9dbde439b754ce52a19fe9804f6c4120e2595c9c32b01995378

Contents?: true

Size: 376 Bytes

Versions: 2

Compression:

Stored size: 376 Bytes

Contents

require 'dry-validation'

class Schema < Dry::Validation::Schema
  key(:email) { |email| email.filled? }

  key(:age) do |age|
    age.int? & age.gt?(18)
  end
end

schema = Schema.new

errors = schema.messages(email: 'jane@doe.org', age: 19)

puts errors.inspect
# []

errors = schema.messages(email: nil, age: 19)

puts errors.inspect
# [[:email, ["email must be filled"]]]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-0.2.0 examples/basic.rb
dry-validation-0.1.0 examples/basic.rb