Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
Just to make it clear, I am all for perf improvements :) to a point where I want to write various extensions in rust for dry and transproc :joy:
Peter Leitzen
@splattael
o^O nice! :D
Piotr Solnica
@solnic
ie form coercions in dry-data or those heavy transformations in transproc...imagine dat speed boost
Peter Leitzen
@splattael
over nine thousand! at least :D
we should do more code compilation in Ruby. read "macros" :D
Piotr Solnica
@solnic
Word
Peter Leitzen
@splattael
@solnic https://gist.github.com/splattael/41a87cbde4cf08efa479 <- idea might boost Type::Hash.*_constructor because we know the attributes upfront
Piotr Solnica
@solnic
:D
Peter Leitzen
@splattael
I like @plexus' macros: https://github.com/plexus/macros
Peter Leitzen
@splattael
@solnic regarding redefining initializer over and over again: splattael/dry-data@922dc4a
gonna stop stealing your time - just my 2 cents :D
Piotr Solnica
@solnic
:ok I see what you did there
Peter Leitzen
@splattael
:D
Lorenzo Arribas
@larribas
Hello guys! I've been toying a bit with dry-validation and I haven't found a way to validate that a Hash has EXACTLY the keys I define in the schema (i.e no extra keys)
Am I missing it? I could try contributing something, otherwise
Krzysztof Wawer
@wafcio
you have key method and optional method for hash keys
Lorenzo Arribas
@larribas
yes, but take for instance the example in the IO page. If you try to validate:
schema.call(email: 'jane@doe.org', age: nil, extra_parameter: "I'm in!")
that would work, right?
Krzysztof Wawer
@wafcio
what do you want validate ?
you can write key(:email) … , key(:age) …, optional(:extra_parameter) … if I good understand
Lorenzo Arribas
@larribas
The thing is, I want to validate a Hash of settings, and I want the settings to be accurate so I can store them in my DB
And I don't want to store extra keys I don't use for anything
That is, I want to validate that what the client is sending me is exactly what I am asking. No more, no less
Krzysztof Wawer
@wafcio
so if hash contains more keys you want to return error, right ?
Lorenzo Arribas
@larribas
yep!
that's right
Krzysztof Wawer
@wafcio
I don’t think so that it is validation part
for sure you are not able to do it by dry-validation right now
Lorenzo Arribas
@larribas
hmm ok. don't you think it would be useful?
Krzysztof Wawer
@wafcio
in some specific case it can be useful, but you can remove extra keys and save only keys which you want
of course it depend on your use case
but as alway you can fork dry-validation, write your feature and send pull-request
Lorenzo Arribas
@larribas
ok. thanks!
Piotr Solnica
@solnic
@larribas hey, it is a feature I plan to add. Right now unexpected keys are ignored but there will be feature to treat unexpected keys as a rule violation
Lorenzo Arribas
@larribas
@solnic Good to know, thanks!

I'm curious to know what do you think of another feature (that promises to be more challenging). I have a tree of nodes (represented as a hash). Each node has some validation constraints, and a "children" key which is an array of descendants.

Currently, I am validating each node separately and traversing the tree via a recursive function, but do you think it would be fitting if one could define a recursive validation right from the schema? Or perhaps it is too awkward?

Piotr Solnica
@solnic
@larribas I want dry-v to support even awkward use cases as that is one of the reasons why it was created
Could you provide a gist presenting your usecase?
Lorenzo Arribas
@larribas
Piotr Solnica
@solnic
@larribas one thing I plan to add is to be able to treat a schema as a rule
so, theoretically you’d be able to apply schema recursively
this would be an interesting use case
it would also help in re-using schemas
Lorenzo Arribas
@larribas
reusing schemas would be a great addition
but even so, referencing the same schema from inside of it may require some kind of lazy evaluation or delayed const_get-ish thing, right?
Piotr Solnica
@solnic
@larribas nah, it would just require some additional interface to specify “validate with self"
as in apply all rules from self
API ideas most welcome :)
Andy Holland
@AMHOL
I always love self
:p