From 8f498eb5905df308d6fefa99255ce1310c387c78 Mon Sep 17 00:00:00 2001 From: j0nimost Date: Mon, 16 May 2022 10:43:47 +0300 Subject: [PATCH] Added checker for Struct types --- framework/src/Volo.Abp.Core/Volo/Abp/Check.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs index b20ef0f247..99c1148971 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs @@ -162,4 +162,17 @@ public static class Check return value; } + + public static T NotDefault( + T value, + [InvokerParameterName][NotNull] string parameterName) + where T : struct + { + if(value.Equals(default(T))) + { + throw new ArgumentException($"{parameterName} has a default value or is empty!", parameterName); + } + + return value; + } }