-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTermiiRequestValidation.cs
More file actions
31 lines (28 loc) · 899 Bytes
/
Copy pathTermiiRequestValidation.cs
File metadata and controls
31 lines (28 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace Termii;
internal static class TermiiRequestValidation
{
public static void Required(string? value, string parameterName)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException($"{parameterName} is required.", parameterName);
}
}
public static void Positive(int value, string parameterName)
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(parameterName, value, $"{parameterName} must be greater than zero.");
}
}
public static void Range(int value, int minimum, int maximum, string parameterName)
{
if (value < minimum || value > maximum)
{
throw new ArgumentOutOfRangeException(
parameterName,
value,
$"{parameterName} must be between {minimum} and {maximum}.");
}
}
}