Hi. I just started using DryValidation (enjoying it so far:-), but I’m facing a strange issue and I couldn’t find any example and it seems like no one has encountered this before.
The problem is that I get NoMethodError: undefined method messages_file= exception whenever I try to set a messages_file via configure.
Am I missing something?
BTW, I’m using dry-validation-0.9.3 with reform-2.2.1.
class UserAuthenticationForm < Reform::Form
property :email
validation :default do
configure { |config| config.messages_file = 'config/error_messages.yml' }
required(:email).filled(:str?)
end
end
And in reform.rb initializer, I have
require "reform/form/dry"
Reform::Form.class_eval do
feature Reform::Form::Dry
end
whenever I try to initialize a new instance of class (via UserAuthenticationForm.new(User.new)), I get: NoMethodError: undefined method `messages_file=' for #<Class:0x007fc2918316d8> Did you mean? messages
This feels like it might be a quirk of Reform’s integration with dry-validation? Might be worth reaching out to the Trailblazer people in gitter or elsewhere?
@Arvinje be aware that some of Reform’s documentation is still in the old (0.6) dry-v. You should look at the tests whilst we update the docs.
@timriley This isn’t a querk with Reform as a Reform validation block is just passed directly to a Dry::Validation.schema. @solnic has the answer, you no longer need the config variable in the configure block and it should work.