public WorkflowRulesValidator() { RuleFor(c => c.WorkflowName).NotEmpty().WithMessage(Constants.WORKFLOW_NAME_NULL_ERRMSG); When(c => c.Rules?.Any() != true, () => { RuleFor(c => c.WorkflowRulesToInject).NotEmpty().WithMessage(Constants.INJECT_WORKFLOW_RULES_ERRMSG); }).Otherwise(() => { var ruleValidator = new RuleValidator(); RuleForEach(c => c.Rules).SetValidator(ruleValidator); }); }
private bool BeValidRulesList(List <Rule> rules) { if (rules?.Any() != true) { return(false); } var validator = new RuleValidator(); var isValid = true; foreach (var rule in rules) { isValid &= validator.Validate(rule).IsValid; if (!isValid) { break; } } return(isValid); }