mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-25 22:01:16 +00:00
version 1.1L
* UI responsive table fix * Background scanning for backends * Callback URL parameter to notify on scan results
This commit is contained in:
@@ -8,9 +8,23 @@ namespace MalwareMultiScan.Api.Attributes
|
||||
/// </summary>
|
||||
public class IsHttpUrlAttribute : ValidationAttribute
|
||||
{
|
||||
private readonly bool _failOnNull;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize http URL validation attribute.
|
||||
/// </summary>
|
||||
/// <param name="failOnNull">True if URL is mandatory, false otherwise.</param>
|
||||
public IsHttpUrlAttribute(bool failOnNull = true)
|
||||
{
|
||||
_failOnNull = failOnNull;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
if (!_failOnNull && string.IsNullOrEmpty(value.ToString()))
|
||||
return ValidationResult.Success;
|
||||
|
||||
if (!Uri.TryCreate((string) value, UriKind.Absolute, out var uri)
|
||||
|| !uri.IsAbsoluteUri
|
||||
|| uri.Scheme.ToLowerInvariant() != "http"
|
||||
|
Reference in New Issue
Block a user