forked from julielerman/TEE14Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guard.cs
25 lines (21 loc) · 727 Bytes
/
Guard.cs
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
//From Pluralsight Domain-Driven Design Fundamentals Course (bit.ly/PS-DDD)
using System;
namespace Shared {
public class Guard {
public static void ForLessEqualZero(int value, string parameterName) {
if (value <= 0) {
throw new ArgumentOutOfRangeException(parameterName);
}
}
public static void ForPrecedesDate(DateTime value, DateTime dateToPrecede, string parameterName) {
if (value >= dateToPrecede) {
throw new ArgumentOutOfRangeException(parameterName);
}
}
public static void ForNullOrEmpty(string value, string parameterName) {
if (String.IsNullOrEmpty(value)) {
throw new ArgumentOutOfRangeException(parameterName);
}
}
}
}