btcpayserver/BTCPayServer/Validations/PubKeyValidator.cs
NicolasDorier b5c6ed3860 Init
2017-09-13 15:55:16 +09:00

28 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);
}
}
}
}