Open hwo411 opened 6 years ago
I'd say Any
would be a better name. WDYT?
@solnic Initially I was thinking about Any
, but there exists Each
operation which operates on array of items and Set
operation, which operates on array of rules. Any
as name is closer to Each
than to Set
and that's why I thought it should have different name than Any
. Also the same is true for ruby Enumerable, which has both each
and any
methods.
@solnic Just after some thinking, we can imagine 2 different groups of operations:
1) Applying a rule to multiple items, Each
already exists, I'd expect also Any
. and some operation either to verify that rule returns true from a
to b
items(or just 1). None
can be a shortcut to Not(Any(...))
or a separate rule, also there can be All
as alias to Each
. Not sure if a rule or shortcut for Not(Each(...))
is required.
2) Applying multiple rules to a single item(it can also be an array, Set
already exists, Part
is in this PR, I'd expect also expect a rule from a
to b
rules are true(or just 1). Not sure about negation, it can be exposed via Not(Part(...))
and Not(Set(...))
, but we can also provide shortcut or rule.
By shortcut I mean applying 2 rules via 1 method/class without creating new kind of operation and new type of ast.
WDYT?
One of the changes I mentioned in: https://discourse.dry-rb.org/t/extensions-for-dry-logic-and-dry-validations-to-support-open-api-schemas/525
I have 2 questions about the implementation: 1) Is name
part
good? 2) Is it enough to returnResult::SUCCESS
or should I put successful or failed rules into successful result?