dry-bot on master
[devtools] config sync (compare)
dry-bot on master
[devtools] config sync (compare)
dry-bot on master
[devtools] config sync (compare)
dry-bot on master
[devtools] config sync (compare)
dry-bot on master
[devtools] config sync (compare)
dry-bot on master
[devtools] config sync (compare)
member
key on Dry::Types
# first I defined my custom Dry Type
module MyApp
module Types
include Dry::Types.module
ArrayOfInts = Types::Form::Array.member(Types::Form::Int)
end
end
# Then I use it on my Schema
optional(:my_ids, [:nil, MyApp::Types::ArrayOfInts]).each(:int?)
optional(:my_ids, [:nil, :array]).each([:nil, Types::Form::Int], :int?)
.Form
schema, I was wondering if/how that worked with the new type specs
Dry::Validation.Form
with type_spec = true
on the configs
+nil+ is not a valid predicate name
require 'bundler/inline'
gemfile(true) { gem 'dry-validation' }
s = Dry::Validation.Schema(build: false) do
required(:age) { int? & gt?(18) }
end
s.ast
# => [[:rule, [:age, [:and, [[:rule, [:age, [:predicate, [:key?, [[:name, :age], [:input, Undefined]]]]]], [:rule, [:age, [:and, [[:rule, [:age, [:key, [:age, [:predicate, [:int?, [[:input, Undefined]]]]]]]], [:rule, [:age, [:key, [:age, [:predicate, [:gt?, [[:num, 18], [:input, Undefined]]]]]]]]]]]]]]]]]
# schema:
required(:name).filled
optional(:age).maybe
# spec:
expect(schema).to have_required_key(:name).filled
expect(schema).to have_optional_key(:age).maybe