public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (string.IsNullOrWhiteSpace(Name)) { yield return(BusinessErrors.FieldNullOrEmpty(nameof(Name))); } if (Id == Guid.Empty) { yield return(BusinessErrors.FieldNullOrEmpty(nameof(Id))); } if (RestartOnFailInterval != null && RestartOnFailInterval <= TimeSpan.Zero) { yield return(TaskErrors.RestartOnFailIntervalMustBePositive); } if (RestartOnFailInterval == null && MaximumRestarts < 1) { yield return(TaskErrors.MaximumRestartsMustBeGreaterThanZero); } if (!Audience.IncludesServer && !Audience.IsAll && !Audience.Any()) { yield return(TaskErrors.NoAudienceGiven); } if (!Commands.Any()) { yield return(TaskErrors.NoCommandsGiven); } }