brightcove / valerie

First class validation library for the JVM
Other
3 stars 0 forks source link

Replace composition methods with addition #11

Closed mwhipple closed 8 years ago

mwhipple commented 8 years ago

The initial implementation uses Groovy style << and >> to allow composing a Check that calls the delegate checks (without any short circuiting). This was an attempt to borrow the existing convention but doesn't match the contract of closure/function composition. (f >> g)(x) should be the equivalent of f(g(x)) but rather than call one Check on the return of the other Check (the ResultMap) Valerie adds the returned ResultMaps together equivalent to f(x) + g(x) so it should be more consistent to use plus/+ for combining the Checks and disabling composition.

This should have minimal impact on deployed client code since this is a relatively low level detail in most uses.

mwhipple commented 8 years ago

This would also free composition to handle other things like pre-validation transformation for which a recipe could be provided.

The equivalent approach in the DSL layer could be to accept an array so the summed Checks could be a comma separated sequence