mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
29 lines
578 B
C#
29 lines
578 B
C#
|
using NBitcoin;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace BTCPayServer.Validations
|
|||
|
{
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|