by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 27 09:03
    Travis dry-rb/dry-transaction (release-0.13) errored (353)
  • May 26 18:01
    marzdrel starred dry-rb/dry-system
  • May 25 09:50
    k0va1 starred dry-rb/dry-monads
  • May 22 10:57
    solnic commented #146
  • May 21 22:24
    armstnp edited #125
  • May 21 22:23
    armstnp edited #125
  • May 21 22:17
    armstnp labeled #125
  • May 21 22:17
    armstnp opened #125
  • May 21 10:54
    jezstephens commented #146
  • May 21 09:25
    solnic labeled #146
  • May 21 09:23
    solnic commented #146
  • May 20 17:41
    jezstephens labeled #146
  • May 20 17:41
    jezstephens opened #146
  • May 19 21:29
  • May 19 13:26
    Springok starred dry-rb/dry-monads
  • May 16 22:52
    flash-gordon commented #402
  • May 16 22:51

    flash-gordon on master

    Fix Constructor custom method d… Merge pull request #402 from ti… (compare)

  • May 16 22:51
    flash-gordon closed #402
  • May 16 19:02
    timstott commented #401
  • May 16 18:59
    timstott opened #402
Piotr Solnica
@solnic
@tak1n ^
Benjamin Klotz
@tak1n
@solnic okay will do
panigrah
@panigrah
@cdennl after you set messages to i18n, where is your custom file?
Christopher Dennl-Ortega Arrieta
@cdennl
@panigrah config/locales/en/custom_dry_v_errors.yml
panigrah
@panigrah
how does dry-v pickup the errors.yml file?
Christopher Dennl-Ortega Arrieta
@cdennl
it doesnt, i18n does
and dry-v relies on i18n in this case
panigrah
@panigrah
so the name of the file can be anything?
Christopher Dennl-Ortega Arrieta
@cdennl
yes
you just have to set config.messages = :i18n to tell dry-v to rely on i18n
and assure that i18n is required before dry stuff
part of my initializer:
```
require 'i18n'
require 'cell/translation'
require 'reform/form/dry'
require 'disposable/twin/coercion'
panigrah
@panigrah
ok. And all messages are directly under errors with the rule name?
errors:
    rule_name1?: "Rule has a problem" 
    rule_name2?: "Another rule problem" 
Christopher Dennl-Ortega Arrieta
@cdennl
well common rules i put directly below errors if they are used in multiple contexts
otherwise i put them under a namespace below rules
en:
  errors:
    in_possession?:                         'is not in possession of deviation'
    is_conversion_correct?:                 'is incorrectly converted from P to $'
    not_blank?:                             'is blank'

    rules:
      auction:
        autobuy_amount_is_above_start_bid?: 'must be greater than start bid'
        currency_accepted?:                 'select at least one currency'
        is_conversion_correct?:             'is incorrectly converted from P to $'
      bid:
        is_no_self_bid?:                    'must not bid on own auction'
        is_running?:                        'is not running'
and then i set config.namespace = :whatever in the repsective validation group
panigrah
@panigrah
aah okay.
I will try this out.
for now I have unique?: 'must be unique' directly under errors:. I did not make sure however to put the i18 before dry-v.
maybe thats why it isnt picking up.
Christopher Dennl-Ortega Arrieta
@cdennl
and remember to restart the server then after adapting your initializer :)
panigrah
@panigrah
no luck.
Dry::Validation::MissingMessageError: message for unique? was not found
Christopher Dennl-Ortega Arrieta
@cdennl
mhh
all my statements are for drv-v 0.7.3
my config block looks like this:
```
configure do
        config.messages   = :i18n
        config.namespace  = :bid
        config.predicates = Dagavel::Predicates

        option :form

        def is_no_self_bid?( user )
          user.id != form.auction.user_id
        end

        def is_running?( auction )
          auction.is_running?
        end
      end
panigrah
@panigrah

this is the yml file

en:
   hello: "Hello world"
   errors:
      unique? : "WTF"

and initializer has required i18n on top before dry-v and reform and configure block has the same

i have 0.7.4 dry-v. I will take a break for now
thanks for your help!
Christopher Dennl-Ortega Arrieta
@cdennl
np
panigrah
@panigrah
@cdennl i just realized - that the global setting that was suggested by AMHOL doesn't work in my case. But if I put config.messages_file into my validation block then it works.
Christopher Dennl-Ortega Arrieta
@cdennl
messages_file or messages?
panigrah
@panigrah
messages_file and messages shows me a different error - perhaps i have a problem with i18 setup
Piotr Solnica
@solnic
You need to make sure i18n loads all your locale files
Christopher Dennl-Ortega Arrieta
@cdennl
my initializer for i18n:
```
# tell the I18n library where to find your translations
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

# set default locale to something other than :en
I18n.default_locale = :en
Pablo Herrero
@pabloh
Sry if this was already asked, why dry-types depends on concurrent-ruby?
Hunter Madison
@hmadison
Thread safety stuff iirc
Piotr Solnica
@solnic
@pabloh we use concurrent::cache
Don Morrison
@elskwid
is this the @solnic hugs chat?
Cause I have one I’d like to give him.
:heart:
Piotr Solnica
@solnic
Heh. It's a dry-rb chat. But we can hug each other nevertheless ;)
Don Morrison
@elskwid
I’ve been lurking around as I do and thought you could use some happy thoughts.
panigrah
@panigrah
@cdennl couldn't get i18n to load. I have to get i18n eventually - but for now - this worked in an initializer. I am using reform 2-2 branch which is setup to use the new dry-v api. @fran-worley if you aren't having luck with the global setup for error messages - this may help.
Dry::Validation::Schema::Form.configure do |config|
  config.messages = :yaml
  config.messages_file =  "#{Rails.root}/config/locales/en/dry-v-custom-messages.yml"
end