You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Common/EnsureThat/EnsureShortExtensions.cs

57 lines
2.1 KiB

using System.Diagnostics;
using NzbDrone.Common.EnsureThat.Resources;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.EnsureThat
{
public static class EnsureShortExtensions
{
[DebuggerStepThrough]
public static Param<short> IsLt(this Param<short> param, short limit)
{
if (param.Value >= limit)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<short> IsLte(this Param<short> param, short limit)
{
if (!(param.Value <= limit))
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<short> IsGt(this Param<short> param, short limit)
{
if (param.Value <= limit)
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<short> IsGte(this Param<short> param, short limit)
{
if (!(param.Value >= limit))
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit));
return param;
}
[DebuggerStepThrough]
public static Param<short> IsInRange(this Param<short> param, short min, short 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;
}
}
}