public AutopilotSettingsModelValidation(IFlexibilityLevelRepository flexibilityLevelRepository) { RuleFor(s => s.DefaultFlexibilityLevelId) .Must(id => flexibilityLevelRepository.Get(id) != null) .WithMessage(s => $"FlexibilityLevel with identifier {s.DefaultFlexibilityLevelId} does not exist"); RuleFor(s => s.ScenariosToGenerate).InclusiveBetween(1, 8).WithMessage("Please specify valid scenario types count to be generated"); }
public AutopilotEngageModelValidation(IFlexibilityLevelRepository flexibilityLevelRepository) { RuleFor(s => s.FlexibilityLevelId) .Must(id => id == 0 || flexibilityLevelRepository.Get(id) != null) .WithMessage(s => $"FlexibilityLevel with identifier {s.FlexibilityLevelId} does not exist"); RuleFor(s => s.Scenarios).Must(s => s != null && s.Any()).WithMessage("Please provide at least one scenario"); RuleForEach(s => s.Scenarios).SetValidator(new AutopilotScenarioEngageModelValidation()); }