aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-06-28 15:52:09 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-06-28 15:52:09 -0400
commit68204a650fa3714c82d99827d74485844a5d6db2 (patch)
tree4de8481be063686f8b069850b7714f26dddf7ee9
parent57c41b14e3f713ea1719489337874dd6f0a8cd5a (diff)
minor things
-rw-r--r--lib/Emails.Transactional.Client/src/Plugins/TEmailConfig.cs25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/Emails.Transactional.Client/src/Plugins/TEmailConfig.cs b/lib/Emails.Transactional.Client/src/Plugins/TEmailConfig.cs
index 1e2f239..97f4c03 100644
--- a/lib/Emails.Transactional.Client/src/Plugins/TEmailConfig.cs
+++ b/lib/Emails.Transactional.Client/src/Plugins/TEmailConfig.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: Emails.Transactional.Client
@@ -38,6 +38,7 @@ using VNLib.Net.Rest.Client;
using VNLib.Net.Rest.Client.OAuth2;
using VNLib.Net.Rest.Client.Construction;
using VNLib.Plugins.Extensions.Loading;
+using VNLib.Plugins.Extensions.Loading.Configuration;
namespace Emails.Transactional.Client.Plugins
{
@@ -208,22 +209,14 @@ namespace Emails.Transactional.Client.Plugins
[JsonIgnore]
public Uri TokenServerUri => new(AuthUrl!);
- void IOnConfigValidation.Validate()
+ void IOnConfigValidation.OnValidate()
{
- _ = EmailFromName ?? throw new KeyNotFoundException("Missing required mail configuration key 'from_name'");
- _ = EmailFromAddress ?? throw new KeyNotFoundException("Missing required mail configuration key 'from_address'");
- _ = ServiceEndpoint ?? throw new KeyNotFoundException("Missing required mail configuration key 'email_url'");
- _ = AuthUrl ?? throw new KeyNotFoundException("Missing required mail configuration key 'auth_url'");
-
- if (MaxClients < 1)
- {
- throw new ArgumentOutOfRangeException("max_client", "Max clients config variable must be a non-zero positive integer");
- }
-
- if (TimeoutMs < 100)
- {
- throw new ArgumentOutOfRangeException("timeout_ms", "Client timeout should be a value greater than 100ms");
- }
+ Validate.NotNull(EmailFromName, "Missing required email 'from_name'");
+ Validate.NotNull(EmailFromAddress, "Missing required email 'from_address'");
+ Validate.NotNull(ServiceUrl, "Missing required email 'email_url'");
+ Validate.NotNull(AuthUrl, "Missing required email 'auth_url'");
+ Validate.Range(TimeoutMs, 100, int.MaxValue, nameof(TimeoutMs));
+ Validate.Range(MaxClients, 1, int.MaxValue, nameof(MaxClients));
}
}