These are chat archives for dry-rb/chat

Dec 2016
Christopher Dennl-Ortega Arrieta
Dec 14 2016 07:51
@ValentinTrinque for arbitrary boolean checks you dont want to use rule but validate, see dry-v docs
rule just works on predicates
Andriy Tyurnikov
Dec 14 2016 13:55
Hello. @timriley do you have some plans about dry-web-roda || icelab/dry-web-skeleton ?
Andriy Tyurnikov
Dec 14 2016 14:38
Basicaly it would be nice to know if you guys fundamentally opposed to idea of adding foreman and dotenv to the dry-web-roda default stack
Ilya Bylich
Dec 14 2016 17:02
Hi there. Currently I'm trying to replace AM::Validations with dry-validations but I can't generate correct error message. Let's say I have a scheme with attribute
optional(:attribute_name) { eql?('') | none? | (str? & format?(/\w+/) & max_size?(10)) }
By calling 'some invalid value').messages
I'm getting errors as a single string
{:attribute_name=>["must be equal to or must be a string or is in invalid format or size cannot be greater than 10"]}
I need to have one error message for all kind of errors, like "Attribute name must contain < 10 symbols from the following list: ..."
Is it possible?
After a quick look at Dry::Validation::MessageCompiler I guess it doesn't support any options for switching generating strategies...
Christopher Dennl-Ortega Arrieta
Dec 14 2016 17:48
@iliabylich write a custom predicate/rule and make a message for it
Ilya Bylich
Dec 14 2016 18:03
This is the default behavior in my system (which means that I have to write custom predicate for each attribute)
I've tried to read the source code of dry-validation and it seems that | (Or) is the only node in produced AST that gets converted to a non-array value
By using &, > or ^ my errors messages are not joined. This code is a problem for me - - and I have no idea how to solve it without patching
Christopher Dennl-Ortega Arrieta
Dec 14 2016 18:09
@iliabylich no you write ONE predicate which does aggregates all the single validations and call this one, and this predicate you can give a custom message
def my_predicate
  return eql? || none? || ... #this is pseudo code

my_predicate: 'custom message'

optional(:attr) { my_predicate }
Tim Riley
Dec 14 2016 20:54
@andriytyurnikov dry-web already has some sort of application config system, but I’m interested in making it behave a little more like dotenv instead of using a .yml file. As for foreman, this seems like something that’s better suited to people’s own skeletons or applications rather than being built in?
Pol Miro
Dec 14 2016 23:36

hi! I'm running into a struggle with dry-transaction and I wonder if it is something any of you have run into.

1)The interface expected is always in the form call(input) but since we have been using dry-initializer a lot, our callable objects are initialized with the input, and called with call() without any arguments.
I can wrap the registered methods so they get called correctly but seems a bit of an overhead. Step adapters don't really solve anything since they adapt the handling of the output but not the way the method is called.
Is there any way to streamline this? Has any of you felt this need before?

Pol Miro
Dec 14 2016 23:43
2) In a similar fashion, the schemas from dry-validation return a Dry::Validation::Result, which resembles a lot to a Dry::Monads::Either class but it's not, so dry-transaction does not work when chaining a dry-validation schema directly. I wonder if the dry-transaction contract could accept results in a more dynamically typed way so that this would not happen.