Sha256: dd4c480971996b0305db667caa6cc40008fdae575cbd9c74a716e0712459a521

Contents?: true

Size: 239 Bytes

Versions: 26

Compression:

Stored size: 239 Bytes

Contents

require 'json'
require 'dry-validation'

schema = Dry::Validation.JSON do
  required(:email).filled

  required(:age).filled(:int?, gt?: 18)
end

errors = schema.call(JSON.parse('{"email": "", "age": "18"}')).messages

puts errors.inspect

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dry-validation-0.13.3 examples/json.rb
dry-validation-0.13.2 examples/json.rb
dry-validation-0.13.1 examples/json.rb
dry-validation-0.11.2 examples/json.rb
dry-validation-0.12.3 examples/json.rb
dry-validation-0.13.0 examples/json.rb
dry-validation-0.12.2 examples/json.rb
dry-validation-0.12.1 examples/json.rb
dry-validation-0.12.0 examples/json.rb
dry-validation-0.11.1 examples/json.rb
dry-validation-0.11.0 examples/json.rb
dry-validation-0.10.7 examples/json.rb
dry-validation-0.10.6 examples/json.rb
dry-validation-0.10.5 examples/json.rb
dry-validation-0.10.4 examples/json.rb
dry-validation-0.10.3 examples/json.rb
dry-validation-0.10.2 examples/json.rb
dry-validation-0.10.1 examples/json.rb
dry-validation-0.10.0 examples/json.rb
dry-validation-0.9.5 examples/json.rb