Closed Kukunin closed 5 years ago
A couple caveats:
attr?
predicatedry-types
uses keys without ?
sign, while dry-validates
expects keys with ?
. dry-logic
: https://github.com/dry-rb/dry-types/blob/f618eda432bbab75a33c7a1457eb267e1ed5dac5/lib/dry/types/constraints.rb#L9, isn't it better to implement such predicate there? There is already attr? predicate
This should be removed
what's the syntax for nested predicates?
What's a "nested predicate"?
dry-types uses keys without ? sign, while dry-validates expects keys with ?.
Yes, because constraints != validation
It'd be good to compose nested predicate failing message based on sub-predicates
Could you explain a bit more? :)
That fact, that hash or rule compiler is implemented outside of dry-logic: https://github.com/dry-rb/dry-types/blob/f618eda432bbab75a33c7a1457eb267e1ed5dac5/lib/dry/types/constraints.rb#L9, isn't it better to implement such predicate there?
This is functionality specific to dry-types. in dry-validation DSL is gazillion times more complex due to all kinds of additional features that dry-v has.
I see. probably the best way is to implement attribute:
predicate in dry-struct
with syntax above
I don't think we'll ever do this. Closing for now. Feel free to bring this up again on our discussion forum.
Can we build predicate which can validate attributes against nested predicates?
It'd be useful for Dry::Struct, something like:
Of course, we can invent better DSL