public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var split = Id.Split(':'); if (split.Length != 2) { yield return(new ValidationResult( $"The {nameof(Id)} field must be separated by exactly one ':'", new[] { nameof(Id) })); } else { if (!int.TryParse(split[1], out var _)) { yield return(new ValidationResult( $"The {nameof(Id)} field must have number after ':'", new[] { nameof(Id) })); } } if (!string.IsNullOrEmpty(ZMQNotificationsEndpoint)) // null/empty string value or "tcp://a.b.c.d:port" { if (!CommonValidator.IsUrlWithUriSchemesValid(ZMQNotificationsEndpoint, nameof(ZMQNotificationsEndpoint), new string[] { "tcp" }, out var error)) { yield return(new ValidationResult(error, new[] { nameof(ZMQNotificationsEndpoint) })); } } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (!string.IsNullOrEmpty(ZMQNotificationsEndpoint)) // null/empty string value or "tcp://a.b.c.d:port" { if (!CommonValidator.IsUrlWithUriSchemesValid(ZMQNotificationsEndpoint, nameof(ZMQNotificationsEndpoint), new string[] { "tcp" }, out var error)) { yield return(new ValidationResult(error, new[] { nameof(ZMQNotificationsEndpoint) })); } } }