finalize refactoring & ready for the PR

This commit is contained in:
Volodymyr Smirnov
2020-10-26 21:24:40 +02:00
parent 14c9c26979
commit 62cdcdbb49
34 changed files with 229 additions and 164 deletions

View File

@@ -0,0 +1,22 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace MalwareMultiScan.Api.Attributes
{
/// <summary>
/// Validate URI to be an absolute http(s) URL.
/// </summary>
internal class IsHttpUrlAttribute : ValidationAttribute
{
/// <inheritdoc />
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;
}
}
}