Next-gen ruby libs! » github.com/dry-rb » website: https://dry-rb.org » forum: https://discourse.dry-rb.org
dry-validation
0.10.4 will be released in foreseeable time?
schema = Dry::Validation.Schema do
required(:login).filled(:bool?)
required(:email).maybe(:str?)
rule(email_presence: [:login, :email]) do |login, email|
login.true?.then(email.filled?)
end
end
schema.call({login: false}).messages
{
:email => [
[0] "is missing"
]
}
require "dry-validation"
schema = Dry::Validation.Schema do
required(:login).filled(:bool?)
required(:email).maybe(:str?)
rule(email_presence: [:login, :email]) do |login, email|
login.true?.then(email.filled?)
end
end
p schema.call({login: false}).messages
{
:email => [
"is missing"
]
}
~/Programowanie/TestDry bundle | grep dry-v
Using dry-validation 0.10.3
~/Programowanie/TestDry be ruby a.rb
{:email=>["is missing"]}
false
, isn't it?
require "dry-validation"
schema = Dry::Validation.Schema do
required(:login).filled(:bool?)
required(:email).maybe(:str?)
rule(email_presence: [:login, :email]) do |login, email|
login.true?.then(email.filled?)
end
end
p schema.call({login: false, email: nil}).messages
{
:email => [
"is missing"
]
}
schema.call({login: false, email: nil}).messages
from your last example probably returns {}
maybe
predicate from that example
optional(:email).maybe(:str?)
is suits better to my case, as I'm building API
output
based on rules?
use dry-t inplace
? how can I replace struct with dry-t?
dry-t
inplace. just PORO + dry-t types
class Customer
def name=(name)
@name = Types::Strict::String[name]
end
end
like this?
dry-container
? I try to test it, but it raises exception saying key is already registered
::Concurrent::Hash.new
::Concurrent::Hash.new
doesn't prevent concurrent loading which is not a safe thing