Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 07 14:03

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 10:01
    Travis dry-rb/dry-view (master) errored (636)
  • Dec 07 09:58
    Travis dry-rb/dry-view (master) errored (635)
  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

John Backus
@backus
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
I didn't get it completely from the changelog
Piotr Solnica
@solnic
@cdennl rule name overrides predicate name
Christopher Dennl-Ortega Arrieta
@cdennl
@cd
Piotr Solnica
@solnic
so foo: %i[one two] will use foo message if it’s present
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic ok so in my errors.yml I only have to specify a string for the rule name then
Joshua Wilcox
@joshuaswilcox

So I tried

        required(:user_id).maybe(:int?)
        required(:global_auth_id).maybe(:str?)

        rule(valid_user: [:user_id, :global_auth_id]) do |user_id, global_auth_id|
          user_id.false?.then(global_auth_id.filled?)
        end

        rule(valid_auth_id: [:user_id, :global_auth_id]) do |user_id, global_auth_id|
          global_auth_id.false?.then(user_id.filled?)
        end

but i get

>> @schema.call(global_auth_id: '2')
=> #<Dry::Validation::Result output={:global_auth_id=>"2"} messages={:user_id=>["is missing"]}>
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic ah it is optional? if it is not present it will use predicate?
Piotr Solnica
@solnic
when it’s missing we won’t apply any other rule
you marked it as required
Joshua Wilcox
@joshuaswilcox
so optional then?
with that I get
>> @schema.call(user_id: nil)
=> #<Dry::Validation::Result output={:user_id=>nil} messages={}>
basically I am trying to use two different params to do the same thing, so either is ok, but at least one and not both, ha
Christopher Dennl-Ortega Arrieta
@cdennl
@joshuaswilcox user_id.filled? xor global_auth_id.filled?
as one rule
Joshua Wilcox
@joshuaswilcox
same result
>> @schema.call(user_id: 1)
=> #<Dry::Validation::Result output={:user_id=>1} messages={:global_auth_id=>["is missing"]}>
>> @schema.call(global_auth_id: '1')
=> #<Dry::Validation::Result output={:global_auth_id=>"1"} messages={:user_id=>["is missing"]}>
>> @schema.call(global_auth_id: '1', user_id: nil)
=> #<Dry::Validation::Result output={:user_id=>nil, :global_auth_id=>"1"} messages={:user_id=>["must be filled"]}>
I think maybe I am approaching my problem the wrong way
Christopher Dennl-Ortega Arrieta
@cdennl
with both marked optional?
nah you don't i have the same sitations
with xor
Joshua Wilcox
@joshuaswilcox
yeah both optional