flash-gordon on v1.3.3
flash-gordon on master
Bump version to 1.3.3 (compare)
flash-gordon on master
Update CHANGELOG (compare)
flash-gordon on master
Halt with mutable backtrace Ex… Merge pull request #116 from jo… (compare)
to_time = -> x { Time.iso8601("#{x}Z") }
ISOTime = Types::Strict::Time.constructor(to_time)
Schema = Dry::Validation.JSON do
optional(:sent_at, :time).value(ISOTime)
...
optional(:sent_at) { time? | value(ISOTime) }
?
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"