These are chat archives for dry-rb/chat

1st
Jan 2019
Oskar Szrajer
@gotar
Jan 01 18:34
Hi, I'm trying to validate something like this in dry-v. a field values is any array of strings, if inside those array there is a value 'foo' it must validate presence of 'bar', 'baz' too, so something like
values.include?('foo') > values.include?('bar') & values.include?('baz')
is it possible? I don't have any good idea how to achieve this
Vasily Kolesnikov
@v-kolesnikov
Jan 01 18:49
I would prefer to avoid that validation at all, even if dry-v could do it. It sounds strange to have data like unstructured array of strings. Could you give a real example of usage the data like that?
Oskar Szrajer
@gotar
Jan 01 18:56
User select answers in a form, it's a checkbox (multiselect) is he select one from them he must select some others.
I found some solution, just a custom predicate, works ok-ish ;]
Vasily Kolesnikov
@v-kolesnikov
Jan 01 18:58
:ok_hand:
Oskar Szrajer
@gotar
Jan 01 18:58
and I'm building this for existing form, cannot change logic/form there