Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 17 13:25
    flash-gordon review_requested #415
  • Jan 17 13:25
    flash-gordon review_requested #415
  • Jan 17 13:25
    flash-gordon opened #415
  • Jan 17 13:21

    flash-gordon on custom-builder-methods

    Support for custom builder meth… (compare)

  • Jan 17 12:37
    flash-gordon synchronize #413
  • Jan 17 12:37

    flash-gordon on or_nil-extension

    Add Type#or_nil via builders ex… (compare)

  • Jan 17 12:30

    dry-bot on master

    [devtools] sync (compare)

  • Jan 17 12:30

    flash-gordon on master

    Fix changelog (compare)

  • Jan 17 10:28

    dry-bot on master

    [devtools] sync (compare)

  • Jan 17 10:28

    flash-gordon on master

    Update changelog.yml Add reminder (compare)

  • Jan 17 10:11

    flash-gordon on deprecate-class-name-inferring

    (compare)

  • Jan 17 10:11

    flash-gordon on master

    Deprecate predicate inferring f… Merge pull request #414 from dr… (compare)

  • Jan 17 10:11
    flash-gordon closed #414
  • Jan 17 05:34
    solnic commented #413
  • Jan 16 20:20
    flash-gordon review_requested #414
  • Jan 16 20:20
    flash-gordon opened #414
  • Jan 16 20:20

    flash-gordon on deprecate-class-name-inferring

    Deprecate predicate inferring f… (compare)

  • Jan 16 16:33
    flash-gordon synchronize #413
  • Jan 16 16:33

    flash-gordon on or_nil-extension

    Add Type#or_nil via builders ex… (compare)

  • Jan 16 16:06
    flash-gordon review_requested #413
Nikita Shilnikov
@flash-gordon
@solnic I pushed a fix ^
just removed that line, I overlooked it, sorry
Joe Van Dyk
@joevandyk
@timriley what's the input macro?
Jānis Miezītis
@janjiss
Folks, I just wanted to say: You are awesome
Nikita Shilnikov
@flash-gordon
:heart:
Piotr Solnica
@solnic
@janjiss <3
@flash-gordon it’d be fine to push 0.10.1 with your fix, I think, wdyt?
@timriley thanks, wasn’t easy, thankfully we’ve got amazing help from contributors :)
now I gotta sum this up in a blog post :sweat_smile:
Nikita Shilnikov
@flash-gordon
@solnic yeah, think so
John Backus
@backus
Good news
I think I found my first dry-v bug of the new release
gem 'dry-validation', '~> 0.10'

require 'dry/validation'

schema =
  Dry::Validation.Schema do
    required(:foo) { str? }
    required(:bar) { str? | int? }
  end

schema.call(foo: 1, bar: 'blah').message_set.first.text # => "must be a string"

begin
  schema.call(foo: 'hi', bar: 1.0).message_set.first.text
rescue => err
  p err
end

# >> #<NoMethodError: undefined method `text' for #<Dry::Validation::Message::Or:0x007fbcb32514b8>>
@solnic or @flash-gordon ^
Is it a bug or were we using private API?
John Backus
@backus
works with #to_s
gem 'dry-validation', '~> 0.10'

require 'dry/validation'

SCHEMA =
  Dry::Validation.Schema do
    required(:foo) { str? }
    required(:bar, %i[string int]) { str? | int? }
  end

SCHEMA.call(foo: 1, bar: 'blah').message_set.first.to_s # => "must be a string"

begin
  SCHEMA.call(foo: 'hi', bar: 1.0).message_set.first.to_s # => "must be a string or must be an integer"
rescue => err
  p err
end
Piotr Solnica
@solnic
@backus #to_s should be used, not text
there’s also Result#errors and Result#hints
John Backus
@backus
cool
thanks
Joe Van Dyk
@joevandyk
I have a form schema called X. How can I validate that an array is filled with X?
http://dry-rb.org/gems/dry-validation/reusing-schemas/ deals with a hash with a key that has a schema of X
Joe Van Dyk
@joevandyk
I tired each { schema X } but got an error
oh hm.. that works with plain schemas, not form schemas
on dry-v master
if I use a form schema, I get:
/home/monkey/.gem/ruby/2.2.5/gems/dry-types-0.9.0/lib/dry/types/compiler.rb:80:in `merge': no implicit conversion of Dry::Types::Safe into Hash (TypeError)
    from /home/monkey/.gem/ruby/2.2.5/gems/dry-types-0.9.0/lib/dry/types/compiler.rb:80:in `each'
that a bug?
Kiril Dokh
@dsounded
@flash-gordon I just though it cause Scala has getOrElse for Try as well, sure, in general you should work around exceptions somehow, but in some cases it could be helpful
Kiril Dokh
@dsounded
@solnic, Am I able to pass a variable to validate error message somehos ?
Kiril Dokh
@dsounded
@flash-gordon WDYT if it would be possible to perform pattern-mathing gem on top of dry-monads and dry-equalizer ?
Kiril Dokh
@dsounded
will check this out
Nikita Shilnikov
@flash-gordon
@dsounded re getOrElse, well, we can add it, though I'd add a disclaimer about its usage in Try and Either :)
re pattern matching, you can use case for simple ugh ... cases
Kiril Dokh
@dsounded
Sure, but currently that gem oriented only for Either like behavior
Nikita Shilnikov
@flash-gordon
in dry-matcher you can write a matcher for an arbitrary type http://dry-rb.org/gems/dry-matcher/
Christopher Dennl-Ortega Arrieta
@cdennl
what exactly is the difference now between hints and errors?
Piotr Solnica
@solnic
@cdennl hints are not errors, they are messages generated from your rule definitions, you can treat them separately to show useful feedback in UI so that the user will know about requirements for a given field
until 0.10 we only have messages that merge both errors and hints, this turned out to be problematic in some cases so it was separated in 0.10.0
Joe Van Dyk
@joevandyk
@solnic should i submit a bug about not being able to reuse form schemas?
each { schema SomeFormSchema } doesnt seem to work. Using a non form schema does.
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic so errors are messages which happened during validations and hints are the stuff which might happen
Joshua Wilcox
@joshuaswilcox
is is possible to have conditional required params in dry-validation? i.e. one of either user_id or username is required?
Christopher Dennl-Ortega Arrieta
@cdennl
@joshuaswilcox yes with high level rules
Joshua Wilcox
@joshuaswilcox
Ah yes I see that now, sorry guess I missed that page all together
Christopher Dennl-Ortega Arrieta
@cdennl
@joshuaswilcox You're welcome
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic Are the messages for high-level rules now ONLY generated from the high-level rules' name and no predicate messages anymore?
when they are inside a highlevel rule