Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Michał Pietrus
@blelump
yep
Piotr Solnica
@solnic
@blelump oops, yeah I missed this case. I’ll fix
Michał Pietrus
@blelump
thx :-)
Michał Pietrus
@blelump
and if I can add a a 5cents to the discussion above, I found valuable the dry-types Hashes as the first step of params filtering, e.g:
permitor = Types::Hash
.schema(user_session: Types::Hash
    .strict(email: Types::String, password: Types::String))
permitor[params]
Piotr Solnica
@solnic
@blelump ok it’s fixed
re params filtering, actually schema should do that for you, which is now a known issue that I’ll address prior 0.7.0 release
Michał Pietrus
@blelump
@solnic thx :-)
Tim Riley
@timriley
@solnic you up for some feedback on dryrb/dry-validation#70 or are you still working through it?
Piotr Solnica
@solnic
@timriley it is a wip but shoot :)
Tim Riley
@timriley
I thought it might be. Was just going to say that the configure do configure do dance felt a bit funny :)
Piotr Solnica
@solnic
Yeah man it is not final
Tim Riley
@timriley
Right :)
Piotr Solnica
@solnic
Just wanted to maintain green build
Tim Riley
@timriley
heh, of course!
Piotr Solnica
@solnic
@AMHOL @timriley morning, seems like the website is in a good shape and now needs copy/content. I’m gonna create a branch and start adding stuff. I’d love to get some feedback, esp re copy :)
Tim Riley
@timriley
I will keep watch on it!
Piotr Solnica
@solnic
ideas/suggestions most welcome, as always
Andy Holland
@AMHOL
Cool, I'll keep an eye out
Piotr Solnica
@solnic
Anybody brave enough to test dry-v from current master? You can check out updated examples to see how it works now. Notice new DSL for defining schemas and ability to define nested schemas via key(:address).schema { .. }. Please try to play with this stuff a little bit, it would be very helpful :) I have a couple of tiny improvements to make and then it’s only a matter of updating docs and pushing a new release. /cc @kwando @fran-worley @blelump @AMHOL @timriley @apotonick @gotar
Michał Pietrus
@blelump
@solnic , bomba! Perhaps tomorrow I'll try to put these changes into reform and see how it spins
Piotr Solnica
@solnic
that would be awesome
Piotr Solnica
@solnic
Dry::Validation.Schema do
  key(:tags).each(:str?)

  rule(red: [[:tags, 0]]) do |value|
    value.eql?('red')
  end
end
this now works too :joy:
Piotr Solnica
@solnic
what’s really cool about this is that it will not crash if tags are not an array
Tim Riley
@timriley
key(:my_key).schema do … end for nested keys makes a lot of sense
Piotr Solnica
@solnic
@timriley you could rely on that in formalist to figure out when you have nested keys
Tim Riley
@timriley
Let me take a look at the AST
Piotr Solnica
@solnic
I believe you want to process schema's instance rules. It is a hash and if a value is another schema then you know what to do
Tim Riley
@timriley
So just schema.rules?
These #inspect outputs are brutal ;)
So for examples/nested.rb, schema.rules[:address] is actually a Dry::Logic::Rule::Conjunction.
Piotr Solnica
@solnic
@timriley it’s not for casual mortals ;)
ah right
sorry, I was being silly with that suggestion. you want to process Schema.rules of course
a nested schema is just a [:schema, schema_class] node
so you basically need a compiler for basic set of rules, and whenever it sees a schema node, it processes it recursively with itself
probably sth like visit_schema(klass); call(klass.rules); end
Tim Riley
@timriley
right! I looked at schema.class.rule_ast before, and it did seem more familiar
Hannes Nevalainen
@kwando
@solnic cannot get your basic example to work https://gist.github.com/kwando/d8ad54d98acc0c6ca7c7
I've not spent a ton of time at this so I might just have missed something obvious
Piotr Solnica
@solnic
@kwando you need dry types and logic from master too
Sorry I forgot to mention that
Hannes Nevalainen
@kwando
ah, I missed dry-logic in my Gemfile
thx for the hint
this reads a little funny optional(:name).required =P
though it appears to do the same as optional(:name, &filled?)
Piotr Solnica
@solnic
It doesn't when you know how it works
Hannes Nevalainen
@kwando
>.< I know
Piotr Solnica
@solnic
Left side == key expectation
Right side == value expectation