public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (DefaultPermissions.Any(x => x.IsNullOrWhiteSpace())) { yield return(new ValidationResult("A permission value cannot be null or empty", new[] { "Permissions" })); } foreach (var assignedPermission in AssignedPermissions) { foreach (var permission in assignedPermission.Value) { if (permission.IsNullOrWhiteSpace()) { yield return(new ValidationResult("A permission value cannot be null or empty", new[] { "AssignedPermissions" })); } } } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (DefaultPermissions?.Any(x => x.IsNullOrWhiteSpace()) ?? false) { yield return(new ValidationResult("A permission value cannot be null or empty", new[] { "Permissions" })); } if (AssignedPermissions is not null) { foreach (KeyValuePair <int, IEnumerable <string> > assignedPermission in AssignedPermissions) { foreach (var permission in assignedPermission.Value) { if (permission.IsNullOrWhiteSpace()) { yield return(new ValidationResult( "A permission value cannot be null or empty", new[] { "AssignedPermissions" })); } } } } }