mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
22 lines
613 B
C#
22 lines
613 B
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace BTCPayServer.Validation
|
|
{
|
|
//from https://stackoverflow.com/a/47196738/275504
|
|
public class UriAttribute : ValidationAttribute
|
|
{
|
|
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
|
{
|
|
Uri uri;
|
|
bool valid = Uri.TryCreate(Convert.ToString(value), UriKind.Absolute, out uri);
|
|
|
|
if (!valid)
|
|
{
|
|
return new ValidationResult(ErrorMessage);
|
|
}
|
|
return ValidationResult.Success;
|
|
}
|
|
}
|
|
}
|