From 3298db7a3add483eaeda1fcd8e72b8c12f72d34f Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Sun, 30 Jun 2024 12:03:21 -0500
Subject: [PATCH] feat: add method to throw if null or whitespace
---
src/AnthropicClient/Utils/ArgumentValidator.cs | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/AnthropicClient/Utils/ArgumentValidator.cs b/src/AnthropicClient/Utils/ArgumentValidator.cs
index fc494d9..375d6f8 100644
--- a/src/AnthropicClient/Utils/ArgumentValidator.cs
+++ b/src/AnthropicClient/Utils/ArgumentValidator.cs
@@ -20,4 +20,19 @@ public static class ArgumentValidator
throw new ArgumentNullException(name);
}
}
+
+ ///
+ /// Throws an if the value is null or empty.
+ ///
+ /// The value to check.
+ /// The name of the value.
+ /// Thrown when the value is null or empty.
+ /// Nothing.
+ public static void ThrowIfNullOrWhitespace(string value, string name)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("Value cannot be null or empty.", name);
+ }
+ }
}
\ No newline at end of file