Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 15 19:07
    jjw starred dry-rb/dry-types
  • Dec 15 18:13

    flash-gordon on master

    Remove unreachable method (compare)

  • Dec 15 18:11

    flash-gordon on master

    Remove Dry::Types.type_keys It… (compare)

  • Dec 15 18:09

    flash-gordon on master

    Remove unreachable code (compare)

  • Dec 15 18:04

    flash-gordon on master

    Coverage for function.rb (compare)

  • Dec 15 17:15

    flash-gordon on fix-maybe-call-safe

    (compare)

  • Dec 15 17:15

    flash-gordon on master

    Fix behavior of Maybe#call_safe… Merge pull request #380 from dr… (compare)

  • Dec 15 17:15
    flash-gordon closed #380
  • Dec 15 17:13
    flash-gordon synchronize #380
  • Dec 15 17:13

    flash-gordon on fix-maybe-call-safe

    Fix behavior of Maybe#call_safe… (compare)

  • Dec 15 17:12
    flash-gordon opened #380
  • Dec 15 17:11

    flash-gordon on fix-maybe-call-safe

    Fix behavior of Maybe#call_safe… (compare)

  • Dec 15 17:00

    flash-gordon on fix-maybe-try

    (compare)

  • Dec 15 17:00

    flash-gordon on master

    Fix behavior of Types::Maybe#try Merge pull request #379 from dr… (compare)

  • Dec 15 17:00
    flash-gordon closed #379
  • Dec 15 15:09

    flash-gordon on master

    Fix typo Merge pull request #67 from gru… (compare)

  • Dec 15 15:09
    flash-gordon closed #67
  • Dec 15 14:43
    flash-gordon opened #379
  • Dec 15 14:43

    flash-gordon on fix-maybe-try

    Fix behavior of Types::Maybe#try (compare)

  • Dec 15 14:30

    flash-gordon on master

    Lax coverage (compare)

Mikhail Slyusarev
@mikhailvs
Is there a way to set a message for a custom dry-validation predicate without loading a yaml file?
Piotr Solnica
@solnic
not yet
I mean…it is possible to merge in your own messages
Mikhail Slyusarev
@mikhailvs
is that not recommended/
what you linked to actually seems like a pretty sane way of doing that
Piotr Solnica
@solnic
well, I don’t like it but it doesn’t mean it’s not recommended. personally I dislike having core objects of my system cluttered with UI-related configurations
Mikhail Slyusarev
@mikhailvs
I can see that. I'd still feel like there's UI stuff polluting backend code with a yaml conf file though... especially with api driven apps.
Piotr Solnica
@solnic
how come? that’s a nice separation, just like you separate html templates from objects that provide data for rendering, it’s somewhat similar here
Mikhail Slyusarev
@mikhailvs
I mean it's stuff that shows up on the frontend, being defined in files of the backend project.
Piotr Solnica
@solnic
you could render them on the client side and have message templates defined there
Mikhail Slyusarev
@mikhailvs
I'm not saying I have a different/better approach though. But it seems like the kind of error something is, is coupled with the text description of it, and since the error is generated on the backend, it's fine for other components of it to be defined there as well.
yeah, that's what I'd do if I felt super strongly about it
Piotr Solnica
@solnic
it’s actually not coupled, we translate generic result object into whatever we want, but since generating string messages is what most people need, it’s been baked into the library
I just made it work with plain YAML because some times you may want to skip i18n as a dependency
Mikhail Slyusarev
@mikhailvs
Well when you create a custom predicate for a schema it seems like there's at least a logical coupling of its definition and the error message it could generate
Piotr Solnica
@solnic
you can still apply that predicate w/o generating a message
messages are generated only when you ask for them
Mikhail Slyusarev
@mikhailvs
as in, when you call .messages?
Piotr Solnica
@solnic
right, or in 0.10.0 errors
Mikhail Slyusarev
@mikhailvs
that makes sense
Piotr Solnica
@solnic
irb(main):004:0> Dry::Validation.Schema { required(:num).value(:int?) }.(num: 'not num').results[0].ast
=> [:key, [:num, [:predicate, [:int?, [[:input, “not num”]]]]]]
^^ here’s a result AST, gives you all info you need to generate whatever you want from it
Mikhail Slyusarev
@mikhailvs
well in my case I do need the message and I'm getting Dry::Validation::MissingMessageError if there isn't one. I think since my schema is in its own file/module it's fine to just put the messages for the custom stuff into the configure block
Piotr Solnica
@solnic
yep, as I said, if you like it, just do it :)
Mikhail Slyusarev
@mikhailvs
fair enough. in any case, separating the schema definition (sans predicate implementation) into its own file makes it sort of like a configuration file anyway
i just dont want to feel bad about what i'm doing... :P
Piotr Solnica
@solnic
it’s gonna be easy to move them to a yaml config when you feel like they make schema defs messy :)
Mikhail Slyusarev
@mikhailvs
i guess my problem is that i'd have to load the file each time i define a schema...
would doing Dry::Validation::Messages.default.merge!(...) one time on app init work?
nvm, doesnt look like theres a merge! implemented
Piotr Solnica
@solnic
Alexander Gräfe
@rickenharp
Is there a way to debug rules in dry-validations? I'm trying to find out what values are actually passed to the rule, but using puts inside the rule leads to +puts+ is not a valid predicate name
Mikhail Slyusarev
@mikhailvs
where in the definition are you using puts?
Alexander Gräfe
@rickenharp
rule(valid_blockname: [:ist_blockname, :name]) do |ist_blockname, name|
  puts ist_blockname
end
Mikhail Slyusarev
@mikhailvs
you should try Kernel.puts
or ::Kernel.puts
Alexander Gräfe
@rickenharp
That works perfectly, thanks!
Alexander Gräfe
@rickenharp
Is it possible to model this in dry-v? first_name and last_name must be filled. Unless blockname is true, in which case first_name must not be filled.
Nikita Shilnikov
@flash-gordon
@solnic I bet this is not :) looking at it
I think before(:all) { load_extension } is a bad approach, should be reworked in the same way as in dry-t
Luca Guidi
@jodosha
@solnic @flash-gordon probably new dry-logic broke rom-sql build (master) See https://gist.github.com/jodosha/55651fe8033477cba882c2af17ee8c9a.
@solnic I confirm that picking dry-types (master) in Gemfile fixes the problem. :)
Benjamin Klotz
@tak1n

@solnic @flash-gordon just updated dry-v on one of our gems and got the same problem :)

https://gist.github.com/tak1n/79c180ac09fbacbae0f432169798233b

Nikita Shilnikov
@flash-gordon
@tak1n have you tried to update dry-logic as well? And, probably, dry-t, dunno
Benjamin Klotz
@tak1n
gem 'dry-struct', github: 'dry-rb/dry-struct'
gem 'dry-validation', github: 'dry-rb/dry-validation'
gem 'dry-types', github: 'dry-rb/dry-types'
putting this into Gemfile fixes the problem
yea I tried to update everything bundle update and tried it explicitly on some gems bundle update --source dry-validation etc
I mean actually I should just need to update dry-v as I'm just using dry-v (and dry-v uses those other gems internally) :)
Egor Lynko
@flexoid

There's also a WIP feature in dry-validation where you can infer validations from a struct definition. It's been in an experimental phase since a couple of releases but we're gonna make it robust prior 1.0.0. (by @solnic)

Is it possible to use this feature, or at lease try it now?

Piotr Solnica
@solnic
@jodosha yeah I know, I need to update/release types and validation
Luca Guidi
@jodosha
@solnic No worries man. Just wanted you and the rest of the team to be aware of it.