Next-gen ruby libs! » github.com/dry-rb » website: https://dry-rb.org » forum: https://discourse.dry-rb.org
:input
nodes could be removed probably
@solnic is there a way to somehow validate hash keys? I would like to describe something like htis:
{ 1 => rand, 2 => rand } # etc
and create sme rules with dry-validations that will ensure that my keys are integer based and that inside there are float numbers as well
schema do .. end
api to achieve this. # If you could name your schemas
schema(:simples) do
# ...
end
schema(:scary_complex) do
# ...
end
# we could enable rules like:
schema(:simples).success?.then schema(:scary_complex)
validation :default do
required(:email).filled
required(:current_password).filled
end
validation :authenticate_current_password, if: :default do
configure do
def account_authenticated?(value)
form.model.authenticate(value)
end
end
required(:current_password, &:account_authenticated?)
end
schema1.and(schema2)
would work
schema1 | schema2
each do
schema do
required(:prefix).filled
required(:value).filled
end
end
required(:something).filled(:str?)
to the new required(:something, :str).filled
?
:input
nodes)…I’m gonna take a break from dry-rb after 0.8.1 release of dry-v to focus on rom-rb so I suspect I won’t be doing much dry-rb work in July
:str?
was doing type checking and coercion?
schemas as rules
idea would help here
:input
nodes anymore
[
[:error, [:name, [:input, [:name, [:result, [nil, [:val, p(:key?, :name)]]]]]]],
[:error, [:gender, [:input, [:gender, [:result, [nil, [:val, p(:key?, :gender)]]]]]]],
[:error, [:age, [:input, [:age, [:result, [18, [:val, p(:gt?, 18)]]]]]]],
[:error, [:email, [:input, [:email, [:result, ["", [:val, p(:filled?)]]]]]]],
[:error, [:address, [:input, [:address, [:result, ["", [:val, p(:filled?)]]]]]]]
]
[:error, [:name, [:result, [nil, [:val, p(:key?, :name)]]]]]
:result
has info about the input for a rule, and its predicate has info about actual args
[:predicate, [:key?, [[:name, nil], [:input, nil]]
[:input, [
:nums, [
:result, [
[1, '3', 3],
[:each, [
[:el, [0, [:result, [1, [:val, [:predicate, [:str?, [[:input, 1]]]]]]]]],
[:el, [2, [:result, [3, [:val, [:predicate, [:str?, [[:input, 3]]]]]]]]]
]]
]
]
]]
# would become:
[ :result, [
[1, '3', 3],
[:each, [
[:el, [0, [:result, [1, [:val, [:predicate, [:str?, [[:input, 1]]]]]]]]],
[:el, [2, [:result, [3, [:val, [:predicate, [:str?, [[:input, 3]]]]]]]]]
]]
]]
[:result, [:nums, […]]]
[ :result, [[:nums, [1, '3', 3]],
[:each, [
[:el, [0, [:result, [1, [:val, [:predicate, [:str?, [[:input, 1]]]]]]]]],
[:el, [2, [:result, [3, [:val, [:predicate, [:str?, [[:input, 3]]]]]]]]]
]]
]]
dry-transaction
to 0.7 i get this in my code undefined method `Right'
include Dry::Monads::Either::Mixin
Dry::Monads.Right(…)
explicitly