Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Rafael George
@cored
you said that you made it work with dry-struct already but not with the optional capabilities
?
Piotr Solnica
@solnic
@cored si
Rafael George
@cored
oki
Piotr Solnica
@solnic
so it’s hard-coded unconditionally right now
Rafael George
@cored
I will start that branch from scratch
too messy at the moment
will close that PR an reopen it when I have something useful
Piotr Solnica
@solnic
you can just force-push to the same branch
no need for another PR
Rafael George
@cored
the good old force push
Piotr Solnica
@solnic
just hard reset to master
Rafael George
@cored
ok I'll do that then
Piotr Solnica
@solnic
and -f push
Kiril Dokh
@dsounded
@solnic Have you taken a look at issue ?
Piotr Solnica
@solnic
@dsounded I did, tbh I didn’t have an immediate idea how this should be done, since it’s a single rule, that is used against multiple values, so I’ve no idea how error messages should be created for this
Kiril Dokh
@dsounded
That’s why I thought about something like :base in Rails validation
So we can store errors like this there
Because this error doesn’t belong to one field, but to couple
Piotr Solnica
@solnic
right, maybe we should add it under rule’s name then?
Kiril Dokh
@dsounded
Makes sense
Piotr Solnica
@solnic
that’s how it used to work btw, but I didn’t like it since for more common cases it was just weird
Kiril Dokh
@dsounded
Hmm, maybe it looks like this, but I do believe it can be repeated in future
Anyway, it’s up to you, I just want somehow this to be able to implement :)
Piotr Solnica
@solnic
well, I was planning to add ability to execute arbitrary validation blocks that are still guarded
but it’d be up to you how to implement it and you’d have to return a result object explicitly
I might be able to do that quickly before 0.10.0
Fran Worley
@fran-worley

@solnic I'm getting a warning (warning: too many arguments for format string) coming through from here:
https://github.com/dry-rb/dry-validation/blob/master/lib/dry/validation/message_compiler.rb#L151

Should we check that there are the correct tokens for the string?

Piotr Solnica
@solnic
@fran-worley oh haven’t thought about that
I guess we should
I didn’t even know this produces a warning :)
Fran Worley
@fran-worley
Yeah, I didn't either. TBF it makes sense when you think about it. Annoying though as we always provide more tokens than are actually used
Piotr Solnica
@solnic
we’d have to parse messages and store info about their tokens
we don’t want to do it all over again during message compilation
Fran Worley
@fran-worley
Yeah adding more overhead especially for valid runs
I've also got these coming through:
dry-validation-0.9.5/lib/dry/validation/schema/value.rb:42: warning: method redefined; discarding old schema
dry-types-0.8.1/lib/dry/types/options.rb:18: warning: method redefined; discarding old meta
dry-types-0.8.1/lib/dry/types/struct/class_interface.rb:65: warning: instance variable @schema not initialized
dry-types-0.8.1/lib/dry/types/struct/class_interface.rb:59: warning: instance variable @constructor_type not
But the messages one is the worst as it comes through for every single message. I know I could just turn warnings of but :monkey_face:
Piotr Solnica
@solnic
I thought we fixed those warnings in dry-struct
Fran Worley
@fran-worley
Possibly thats coming through form old dry-types
Piotr Solnica
@solnic
oh right
Piotr Solnica
@solnic
@fran-worley just added support for arbitrary validation blocks: dry-rb/dry-validation@8922ac0
@dsounded ^^ this will make things simpler for you, but I still need to figure out a way for defining that error message should be attached to something else than the last attribute name in the list of rule deps
ie right now doing validate(foo?: [:bar, :baz, :foo]) { … } will attach error messages to :foo key (the last dependency)
Fran Worley
@fran-worley
@solnic what's the difference between these and high level rules?
My end goal is to be able to essentially validate X schema if Y schema passes
Piotr Solnica
@solnic
@fran-worley this allows arbitrary code
and it’s executed in the context of the schema object
so self in this block is a schema
Fran Worley
@fran-worley
So in theory you could make another validate block a dependency ?
Piotr Solnica
@solnic
yes, I always wanted to support that
but first I need to figure out how to identify them and how to enforce error key so that it doesn’t default to the last dep name