using System; using System.ComponentModel.DataAnnotations; namespace MalwareMultiScan.Api.Attributes { /// /// Validate URI to be an absolute http(s) URL. /// internal class IsHttpUrlAttribute : ValidationAttribute { /// protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (!Uri.TryCreate((string)value, UriKind.Absolute, out var uri) || !uri.IsAbsoluteUri || uri.Scheme != "http" && uri.Scheme != "https") return new ValidationResult("Only absolute http(s) URLs are supported"); return ValidationResult.Success; } } }