Closed jdromeiro closed 1 year ago
Currently, value conditions and composed conditions are written as below:
Value Conditions
.WithCondition(c => c.AsValued(AnimalConditionType.Animal) .OfDataType<string>().WithComparisonOperator(Operators.Equal) .SetOperand("Dog") .Build())
Composed Conditions
.WithCondition(x => { return x.AsComposed() .WithLogicalOperator(LogicalOperators.And) .AddCondition(c => c.AsValued(ConditionTypes.Artist) .OfDataType<string>() .WithComparisonOperator(Operators.Equal) .SetOperand("Queen") .Build()) .AddCondition(c => c.AsValued(ConditionTypes.Lyrics) .OfDataType<string>() .WithComparisonOperator(Operators.Contains) .SetOperand("real life") .Build()) .AddCondition(c => c.AsValued(ConditionTypes.ReleaseYear) .OfDataType<int>() .WithComparisonOperator(Operators.GreaterThanOrEqual) .SetOperand(1973) .Build()) .AddCondition(c => c.AsValued(ConditionTypes.ReleaseYear) .OfDataType<int>() .WithComparisonOperator(Operators.LesserThan) .SetOperand(1977) .Build()) .Build(); })
It would be nice to have a simpler way to build the rule conditions.
As I see it, ideally we would benefit from building Value Conditions like:
.WithValueCondition<string>(AnimalConditionType.Animal, Operators.Equal, "Dog")
and Composed Conditions like:
.WithComposedCondition(LogicalOperators.And, x => x .AddValueCondition<string>(ConditionTypes.Artist, Operators.Equal, "Queen") .AddValueCondition<string>(ConditionTypes.Lyrics, Operators.Contains, "real life") .AddValueCondition<int>(ConditionTypes.ReleaseYear, Operators.GreaterThanOrEqual, 1973) .AddValueCondition<int>(ConditionTypes.ReleaseYear, Operators.LesserThan, 1977))
Not sure what may be obstacles to achieve this.
Not yet
No response
Please consider the implementation related to these issues: https://github.com/Farfetch/rules-framework/issues/21, https://github.com/Farfetch/rules-framework/issues/88
Is your request related to a problem you have?
Currently, value conditions and composed conditions are written as below:
Value Conditions
Composed Conditions
It would be nice to have a simpler way to build the rule conditions.
Describe the solution you'd like
As I see it, ideally we would benefit from building
Value Conditions
like:and
Composed Conditions
like:Not sure what may be obstacles to achieve this.
Are you able to help bring it to life and contribute with a Pull Request?
Not yet
Additional context
No response