abpframework/abp · error · ArgumentException
{parameterName} is out of range min: {minimumValue} - max: {
Error message
{parameterName} is out of range min: {minimumValue} - max: {maximumValue} What it means
Thrown by Check.Range(Int16 value, string, Int16 minimumValue, Int16 maximumValue) when value < minimumValue or value > maximumValue. Reports both bounds in the message so the caller sees the accepted window. ArgumentException carrying the parameter name.
Source
Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Check.cs:266
{
throw new ArgumentException($"{parameterName} is equal to zero");
}
else if (value < 0)
{
throw new ArgumentException($"{parameterName} is less than zero");
}
return value;
}
public static Int16 Range(
Int16 value,
[InvokerParameterName][NotNull] string parameterName,
Int16 minimumValue,
Int16 maximumValue = Int16.MaxValue)
{
if (value < minimumValue || value > maximumValue)
{
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
}
return value;
}
public static Int32 Range(
Int32 value,
[InvokerParameterName][NotNull] string parameterName,
Int32 minimumValue,
Int32 maximumValue = Int32.MaxValue)
{
if (value < minimumValue || value > maximumValue)
{
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
}
return value;
}
View on GitHub (pinned to 7ed43b1931)
Solutions
- Bring the value within [minimumValue, maximumValue] (clamp or correct the source).
- If the bounds are wrong, update the minimumValue/maximumValue arguments to match the real domain constraint.
- Enforce the range at the DTO/UI boundary ([Range]) so users get validation feedback instead of an exception.
- Distinguish 'unset' (use nullable + NotNull) from 'invalid' to avoid the default-0 trap when minimum > 0.
Example fix
// before Check.Range(priority, nameof(priority), (short)1, (short)10); // priority == 0 -> throws // after Check.Range((short)Math.Clamp(priority, 1, 10), nameof(priority), (short)1, (short)10);
Defensive patterns
Strategy: validation
Validate before calling
// Clamp Int16 into the accepted window before guarding short safe = Math.Clamp(value, minimumValue, maximumValue); Check.Range(safe, nameof(value), minimumValue, maximumValue);
Type guard
static bool InRangeShort(short v, short min, short max) => v >= min && v <= max;
Prevention
- Keep [Range(min, max)] on the DTO in sync with the Check.Range bounds.
- Beware the default-0 trap when minimumValue > 0; default such fields to a valid value.
- Unit-test the boundary values (min-1, min, max, max+1).
When it happens
Trigger: Calling Check.Range(port, nameof(port), (short)1, (short)65535) with port outside [1,65535]; or any Int16 field with explicit bounds (priority, percentage 0-100, ordinal position).
Common situations: A port/percentage/priority field out of its allowed window; default value of 0 rejected when minimum is 1; an enum-to-int cast landing outside the accepted range; bounds tightened without updating callers.
Related errors
- {parameterName} is equal to zero
- {parameterName} is less than zero
- {parameterName} (type of {type.AssemblyQualifiedName}) shoul
- Given tenant doesn't exist: {0}
- Given tenant isn't available: {0}
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/cfc4c656d6533760.
Report an issue: GitHub.