solnic on v0.9.0
dry-bot on master
[devtools] sync (compare)
solnic on master
Update changelog.yml Bump dry-matcher to 0.9.0 (compare)
dry-bot on master
[devtools] update changelog.yml… [devtools] sync (compare)
solnic on master
Turn evaluator into an Object d… Merge pull request #32 from dry… (compare)
timriley on add-0-19-0-changelog
Add changelog entry for 0.19.0 (compare)
timriley on add-0-19-0-changelog
Add changelog entry for 0.19.0 (compare)
I've found that, at least in my specific case,
each do
schema do
#some schema here
end
end
is not equivalent to
FunSchema = Dry::Validation.Schema do
# some schema here
end
# ... another schema
each do
schema(FunSchema)
end
PredefinedSchema = Dry::Validation.Schema do
required(:audience).filled(:str?)
end
ComparisonSchema = Dry::Validation.Schema do
%i(lt gt lte gte).each do |key|
optional(key).maybe { int? | float? | time? }
end
end
ParamSchema = Dry::Validation.Schema do
required(:to) do
str? & eql?('*') | schema(PredefinedSchema) | each do
schema do
required(:name).filled(:str?)
required(:criteria).each do
str? | int? | float? | time? | schema(ComparisonSchema)
end
end
end
end
end
CriterionSchema = Dry::Validation.Schema do
required(:name).filled(:str?)
required(:criteria).each do
str? | int? | float? | time? | schema(ComparisonSchema)
end
end
ParamSchema = Dry::Validation.Schema do
required(:to) do
str? & eql?('*') | schema(PredefinedSchema) | each do
schema(CriterionSchema)
end
end
end
user_messages[:filled?, rule: :address]
returns nil not the provided custom message
oh no, the example is wrong. It should no be nested in another rules
.
en:
errors:
rules:
user:
filled?: "name cannot be blank"
rules:
address:
filled?: "You gotta tell us where you live"
should be
en:
errors:
rules:
user:
filled?: "name cannot be blank"
address:
filled?: "You gotta tell us where you live"
messages = Dry::Validation::Messages::YAML.load(['/tmp/errors.yml'])
user_messages = messages.namespaced(:user)
user_messages[:filled?, rule: :address] # => "You gotta tell us where you live"
required(:status, Status)
but that didn't seem to work