From 38f25644cb23824dfc8140e74fbb3b409ec05051 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 21 May 2024 15:36:56 +0900 Subject: [PATCH] introduce AddressValidator --- Mimir/Validators/AddressValidator.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Mimir/Validators/AddressValidator.cs diff --git a/Mimir/Validators/AddressValidator.cs b/Mimir/Validators/AddressValidator.cs new file mode 100644 index 00000000..fd7dc30c --- /dev/null +++ b/Mimir/Validators/AddressValidator.cs @@ -0,0 +1,25 @@ +using Libplanet.Crypto; + +namespace Mimir.Validators; + +public static class AddressValidator +{ + public static bool TryValidate( + string addressString, + out Address address, + out string? errorMessage) + { + try + { + address = new Address(addressString); + errorMessage = null; + return true; + } + catch (ArgumentException e) + { + address = default; + errorMessage = e.Message; + return false; + } + } +}