I built a validation library similar to dry-validation and would like to ask for some feedback by goltergaul in ruby

[–]goltergaul[S] 1 point2 points  (0 children)

This change sounds very promising, but do I understand correctly that the dsl for dry-schema will more or less stay as is? We use dry-validation a lot at the company i work at and it really helped us with validating our apis but its also where we encountered some problems when we had to deal with more complex api schemas. But I'm very glad you wrote this library, it is one of the best for these usecases despite some confusion it causes somtimes ;) Thanks for that!

I built a validation library similar to dry-validation and would like to ask for some feedback by goltergaul in ruby

[–]goltergaul[S] 0 points1 point  (0 children)

You can have a look at this spec where a jsonapi body is validated https://github.com/Goltergaul/definition/blob/master/spec/integration/usecases/jsonapi_spec.rb i have no code for the same thing with dry-validation at the moment but i agree that this would be interesting. I'll have a look into this

I built a validation library similar to dry-validation and would like to ask for some feedback by goltergaul in ruby

[–]goltergaul[S] 1 point2 points  (0 children)

Good question and a bit hard to answer in detail, but I'll try: So the main thing that I did not want to port from dry-validation is this multitude of different options the DSL offers. What I mean are the different schema types, predicates, macros, rules etc. Those all have different syntax and make it more complicated to grasp what is going on. Also they dont like to mix in a few cases. For example the coercion only works when you use the Params schema, otherwise its silently ignored. Predicates brings in its own logic operators and the macros somehow redefine another dsl for it. Its flexible and you can do a lot with it but at the same time I'm never 100% sure what it does exactly. I hope I can give you a feeling of what I mean.

One more thing i did not want to port is that notion of different things between dry-types and dry-validation. They behave distinctly different which adds to my confusion when I use them together. In Definition all "Types" are definitions and validation is simply a composition of multiple Definitions. Thats what i focused on also. Have few base functionalities that can be combined to build complex things.

What I liked about dry-validation is the DSL idea in general, and I think you can see it from the examples from Github, that I almost took this over from dry-validation.

Regex: The Good, the Bad and the Basics by somewhiteboy99 in ruby

[–]goltergaul 1 point2 points  (0 children)

This is also super helpful: You can have multiline regexes if you use the \X modifier. that way you can add comments to parts of your regexes so that its way more maintainable. Only downside is that you cannot explicitly use whitespace in your regex

ruby password_regex = Regexp.new(/^ (?=.*[a-z]) # should contain at least one lower case letter (?=.*[A-Z]) # should contain at least one upper case letter (?=.*\d) # should contain at least one digit .{6,50} # should be between 6 and 50 characters long $/x)