Skip to content

Commit caaefe4

Browse files
committed
[New] ParameterValidator
1 parent db659bd commit caaefe4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
namespace Redmine.Net.Api.Internals;
4+
5+
/// <summary>
6+
///
7+
/// </summary>
8+
internal static class ParameterValidator
9+
{
10+
public static void ValidateNotNull<T>(T parameter, string parameterName)
11+
where T : class
12+
{
13+
if (parameter is null)
14+
{
15+
throw new ArgumentNullException(parameterName);
16+
}
17+
}
18+
19+
public static void ValidateNotNullOrEmpty(string parameter, string parameterName)
20+
{
21+
if (string.IsNullOrEmpty(parameter))
22+
{
23+
throw new ArgumentException("Value cannot be null or empty", parameterName);
24+
}
25+
}
26+
27+
public static void ValidateId(int id, string parameterName)
28+
{
29+
if (id <= 0)
30+
{
31+
throw new ArgumentException("Id must be greater than 0", parameterName);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)