protected IComparisonResult OnlyExists <T1>(T1?parent, ISet <string> fields, string name) where T1 : class, IRosettaModelObject <T1> { if (parent == null) { return(ComparisonResult.FailureEmptyOperand($"Object {name} does not exist")); } var validationResult = parent.MetaData.OnlyExistsValidator.Validate(parent, fields); if (validationResult.IsSuccess) { return(ComparisonResult.Success()); } return(ComparisonResult.Failure(validationResult.FailureReason)); }
private IComparisonResult?ExecuteDataRule(T obj) { var comparisonResult = RuleIsApplicable(obj); // Only evaluate if applicable if (comparisonResult?.Result == true) { comparisonResult = EvaluateThenExpression(obj) ?? ComparisonResult.FailureEmptyOperand("No result from then expression"); } else { comparisonResult = null; } return(comparisonResult); }
private IComparisonResult CombineIgnoreEmptyOperand(IComparisonResult?other, BooleanFunc booleanFunc) { if (this.EmptyOperand && other?.EmptyOperand == true) { return(ComparisonResult.FailureEmptyOperand($"{this.Error} and {other?.Error}")); } if (this.EmptyOperand) { return(other ?? ComparisonResult.FailureEmptyOperand(this.Error)); } if (other?.EmptyOperand == true) { return(this); } return(booleanFunc(other)); }
protected IComparisonResult Or(IComparisonResult?left, IComparisonResult?right) => left?.Or(right) ?? right ?? ComparisonResult.FailureEmptyOperand("Missing operands for Or");
protected IComparisonResult And(IComparisonResult?left, IComparisonResult?right) => left?.And(right) ?? ComparisonResult.FailureEmptyOperand("Missing left operand for And");