1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00
Radarr/NzbDrone.Common/EnsureThat/EnsureDecimalExtensions.cs

56 lines
2.1 KiB
C#
Raw Normal View History

using System.Diagnostics;
using NzbDrone.Common.EnsureThat.Resources;
namespace NzbDrone.Common.EnsureThat
{
public static class EnsureDecimalExtensions
{
[DebuggerStepThrough]
public static Param<decimal> IsLt(this Param<decimal> param, decimal limit)
{
if (param.Value >= limit)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<decimal> IsLte(this Param<decimal> param, decimal limit)
{
if (!(param.Value <= limit))
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<decimal> IsGt(this Param<decimal> param, decimal limit)
{
if (param.Value <= limit)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<decimal> IsGte(this Param<decimal> param, decimal limit)
{
if (!(param.Value >= limit))
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<decimal> IsInRange(this Param<decimal> param, decimal min, decimal max)
{
if (param.Value < min)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min));
if (param.Value > max)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max));
return param;
}
}
}