Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 05 09:29

    solnic on master

    Clear exception message when an… Add gem names to plugins Merge pull request #128 from sk… (compare)

  • Dec 05 09:29
    solnic closed #128
  • Dec 05 09:29
    solnic closed #127
  • Dec 04 18:49
    micahphone starred dry-rb/dry-monads
  • Dec 04 17:43
    icy-arctic-fox starred dry-rb/dry-types
  • Dec 02 12:37
    pedrofurtado starred dry-rb/dry-view
  • Dec 02 11:59
    lenon starred dry-rb/dry-monads
  • Dec 01 11:06

    flash-gordon on declare-finalized

    (compare)

  • Dec 01 11:06

    flash-gordon on master

    Set initial value for ivar Merge pull request #131 from dr… (compare)

  • Dec 01 11:06
    flash-gordon closed #131
  • Dec 01 11:05
    flash-gordon opened #131
  • Dec 01 11:03

    flash-gordon on declare-finalized

    Set initial value for ivar (compare)

  • Nov 30 16:50
    paul commented #32
  • Nov 30 16:50
    paul synchronize #32
  • Nov 30 16:44
    paul synchronize #32
  • Nov 30 16:02
    paul synchronize #32
  • Nov 30 16:01
    paul commented #32
  • Nov 30 12:12

    flash-gordon on master

    Use GH badge for CI status (compare)

  • Nov 30 12:08

    dry-bot on master

    [devtools] config sync (compare)

Oskar Szrajer
@gotar
chages required (I assume are required) for dry-monitor are super easy, both for app generator to drop custom logger and add two directories
Piotr Solnica
@solnic
@gotar yeah I didn’t have time to update generators
I’ll add docs over the weekend while flying to AU :laughing:
btw we follow “shifted semver” so if you see a minor bump while we’re still in beta (and all dry gems are in beta) then it means a breaking change
and re logger, just configure config.logger = YourMainContainer[:logger] in sub-apps
unless you want separate loggers per app
Darcy Laycock
@Sutto
@solnic when do you get in?
Piotr Solnica
@solnic
@Sutto Sunday morning
we’re going to London first, spending the night, then jumping on a plane on Saturday again
Darcy Laycock
@Sutto
awesome - all sorted for when you get here?
Piotr Solnica
@solnic
I hope so :laughing:
Darcy Laycock
@Sutto
The Rubyconf AU organisers are usually pretty fantastic at having all basses covered haha
Piotr Solnica
@solnic
oh yes they are amazing
Tim Riley
@timriley
@solnic FYI: I’m working on updating the dry-web-roda generators
Pat Collins
@patcoll
If I want to validate a list of email addresses at a particular key, what would be the syntax to do that?
Jonah
@jonahx
I’m trying to create a custom form validation. I got the validation part working but not sure how to customize the coercion part automatically. Here’s what I have so far:
schema = Dry::Validation.Form do
  configure do
    def future_date?(value)
      Date.new < Date.parse(value)
    end
  end
  required(:date).filled(:future_date?)
end
Piotr Solnica
@solnic
@jonahx filled(:date?, :future_date?)
Jonah
@jonahx
@solnic ah, so simple. ty sir!
@solnic but say i needed to coerce to some custom object, MyCustomObj. is this easily possible too?
Piotr Solnica
@solnic
@jonahx why?
Jonah
@jonahx
@solnic, i’m not sure i understand the question. why do you coerce into built-in ruby objects like Date or Integer?
Piotr Solnica
@solnic
why you want to coerce to a custom object :)
Jonah
@jonahx
i’ll make an example, since my current example the above works well :). but say user enters a hex value for a color into a form. i want to validate it’s a valid hex value and coerce into a custom Color object that has some nice methods for working with colors, say.
Piotr Solnica
@solnic
do you need a color object for something else than the validation?
Jonah
@jonahx
yeah the “domain” code that uses the params is what would use it. So no, the Color wouldn’t be used within the validation.
Piotr Solnica
@solnic
@jonahx you can do this for more control http://dry-rb.org/gems/dry-validation/input-preprocessing/
explicit type specs will be default API in 1.0.0 btw
Jonah
@jonahx
@solnic thx for link i will reread that part. one more quick question is there a quick way to define error messages without going through a custom yaml file? eg, in this case i only need to define a single error message for this one custom future_date? method and i’d prefer to define it in code near where future_date itself is defined
I guess we should document this
Jonah
@jonahx
@solnic cool, ty. i was just in the midst of using pry to try to figure that out :), you saved me some minutes. i’d even recommend a chrome method over that , but that might be a micro-optimization
Jonah
@jonahx
@solnic I’m getting an uninitialized constanct Messages error:
schema = Dry::Validation.Form do
  configure do
    def future_date?(value)
      Date.today < value
    end
    def self.messages
      Messages.default.merge(
        en: { errors: { future_date?: 'Date must be in the future' } }
      )
    end
  end
  required(:date).filled(:date?, :future_date?)
end
i thought it was because i was in Form instead of Schema but Schema isn’t working for me either...
Jonah
@jonahx
@solnic finally got it working. not sure if it’s the best way or why the way in your spec didn’t work for me, but the following works:
schema = Dry::Validation.Form do
  configure do
    def future_date?(value)
      Date.today < value
    end
    def self.messages
      default_messages.merge(
        en: { errors: { future_date?: 'Date must be in the future' } }
      )
    end
  end
  required(:date).filled(:date?, :future_date?)
end
Piotr Solnica
@solnic
@jonahx IIRC we have include Dry::Validation in spec_helper there heh
which is probably a stupid idea
Jonah
@jonahx
@solnic do i have the Piotr stamp of approval on what I did above? :)
Piotr Solnica
@solnic
@jonahx does it work? :D
Jonah
@jonahx
@solnic it does! i think it would be better to merge on messages rather than default_messages, but you get infinite recursion doing that...
Piotr Solnica
@solnic
it’s tricky stuff
defo a focus for 1.0.0
(to improve it)
Jonah
@jonahx
ok thx. for my immediate purposes this is totally fine, so nbd
Piotr Solnica
@solnic
cool
I’m not a fan of defining user-facing things in code, hence I didn’t add any nice way of defining custom messages inside code
it’s possible, but I don’t like it
I get that people often just need the quick’n’dirty solution though
and adding a special yaml file is not always desirable
I just didn’t have the need for a different approach than a yaml file because my context has been always an app with locales, where I keep dry-v’s messages
Jonah
@jonahx
@solnic fair enough. i agree in most apps of any size at all a yaml file is a better way to go. i just happen to making literally a single page form tool