solnic on master
Cast identifier to String durin… Merge pull request #169 from ad… (compare)
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
Hi. First of all thank you for great dry-rb
gems. Dry-v is awesome! :) I have a problem. I would like to build form schema where some fields are known and some other fields should be dynamically created. I thought that I use Form.with(custom_struct: custom_struct).(params)
with option
within configure
block [like here: http://dry-rb.org/gems/dry-validation/custom-validation-blocks/] but it doesn't work. I cannot use custom_struct
inside the schema definition:
Form = Dry::Validation.Form do
configure do
option :custom_struct
end
required(:name).filled(:str?)
required(:surname).filled(:str?)
optional(:custom).schema do
# error: "undefined method `each' for #<UnboundMethod:0x007f91b9978608> (NoMethodError)"
custom_struct.each do |element|
required(element.name)
end
end
end
I've found this topic [https://discuss.dry-rb.org/t/build-dry-validations-dynamically/164] in the forum but need some examples. Could you help me somehow? Thanks!
Dry::Types
as my sample library. Figured I would share here :P https://github.com/backus/yardcheck
Dry::Types::Type
so that a ton of the params and returns didn't have to be like
# @return [Constrained, Definition, Sum, Safe]