2020-06-29 04:44:35 +02:00
|
|
|
using System;
|
2017-09-13 08:47:34 +02:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-06-28 10:55:27 +02:00
|
|
|
using NBitcoin;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
2018-11-06 07:38:07 +01:00
|
|
|
namespace BTCPayServer.Validation
|
2017-09-13 08:47:34 +02:00
|
|
|
{
|
2017-10-27 10:53:04 +02:00
|
|
|
public class PubKeyValidatorAttribute : ValidationAttribute
|
|
|
|
{
|
|
|
|
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
|
|
|
{
|
|
|
|
if (value == null)
|
|
|
|
{
|
|
|
|
return ValidationResult.Success;
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
new PubKey((string)value);
|
|
|
|
return ValidationResult.Success;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
return new ValidationResult(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|