Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow global configuration for dry-validation #378

Closed
gorkunov opened this issue Jul 2, 2016 · 5 comments
Closed

Allow global configuration for dry-validation #378

gorkunov opened this issue Jul 2, 2016 · 5 comments

Comments

@gorkunov
Copy link

gorkunov commented Jul 2, 2016

Current dry-v version allows global configuration (useful for custom predicates and messages settings):

Dry::Validation::Schema.configure do |config|
  config.messages = :i18n
  config.predicates = MyPredicates
end

Currently there is no way to handle this in reform and we need manually configure each validation block in form.
It would be much useful to set this configuration only once in global reform config.

Related discussion #377

@fran-worley
Copy link
Collaborator

As of Reform 2.3 you will be able to either monkey patch reforms base schema (https://github.com/apotonick/reform/blob/master/lib/reform/form/dry.rb#L26) or pass your own into a validation block see this test for an example:
https://github.com/apotonick/reform/blob/master/test/validation/dry_validation_test.rb#L137

@siassaj
Copy link

siassaj commented Jun 12, 2017

Dry::Validation::Schema::Form.configure do |config|
  config.messages = :i18n
end

@fran-worley
Copy link
Collaborator

That is handy to know, I assumed you had to define a base class as per their docs:
http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/

@siassaj
Copy link

siassaj commented Sep 29, 2017

wow. I just googled 'configure dry validations globally' and found my own answer ...

@trailblazer trailblazer deleted a comment from siassaj Sep 29, 2017
@micdahl
Copy link

micdahl commented Sep 29, 2017

@fran-worley (or someone else)
Could you please explain, how concrete to get i18n running? I have tried different methods which did not lead to a satisfying result (see reform-rails issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants