These are chat archives for dry-rb/chat

3rd
Jul 2017
Jonas Amundsen
@badeball
Jul 03 2017 08:19
Hi! Is it possible to create a string type that accepts both "foo" and "f.o.o", but coerces that latter to "foo"?
Andriy Tyurnikov
@andriytyurnikov
Jul 03 2017 21:59
There is some similarity between dry-rb gems and https://github.com/english/speculation (which is a Ruby port of clojure.spec), however clojure.spec and speculation both have generative ability - specification of structure with types and predicate logic may be used to generate data that conforms to specification, which may be quite big thing for generative testing (a lot of my tests are filled with setup code). Any comments on that? Any plans to add generative ability to dry-types/dry-validation ? Thanks in advance.
Nikita Shilnikov
@flash-gordon
Jul 03 2017 22:05
@andriytyurnikov AFAIK we don't have any plans for this yet but this is definitely possible. Both dry-types and dry-validation support dumping to AST and it quite easily can be used for building data generators
Andriy Tyurnikov
@andriytyurnikov
Jul 03 2017 22:21
@flash-gordon , thanks. AST that you mentioned is not Ruby AST, but AST of dry-logic evaluator ?
Nikita Shilnikov
@flash-gordon
Jul 03 2017 22:25
yes, not only dry-logic however, dry-t/dry-v have their own objects and ASTs
 :003 > Types::Strict::String.constrained(size: 10..20).to_ast
 => [:constrained, [[:definition, [String, {}]], [:and, [[:predicate, [:type?, [[:type, String], [:input, Undefined]]]], [:predicate, [:size?, [[:size, 10..20], [:input, Undefined]]]]]], {}]]
e.g.^
Andriy Tyurnikov
@andriytyurnikov
Jul 03 2017 22:33
@flash-gordon , thanks-a-lot, will take a look