{"record":{"id":"cfc4c656d6533760","repo":"abpframework/abp","slug":"parametername-is-out-of-range-min-minimumvalue","errorCode":null,"errorMessage":"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}","messagePattern":"(.+?) is out of range min: (.+?) - max: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Check.cs","lineNumber":266,"sourceCode":"        {\n            throw new ArgumentException($\"{parameterName} is equal to zero\");\n        }\n        else if (value < 0)\n        {\n            throw new ArgumentException($\"{parameterName} is less than zero\");\n        }\n        return value;\n    }\n\n    public static Int16 Range(\n        Int16 value,\n        [InvokerParameterName][NotNull] string parameterName,\n        Int16 minimumValue,\n        Int16 maximumValue = Int16.MaxValue)\n    {\n        if (value < minimumValue || value > maximumValue)\n        {\n            throw new ArgumentException($\"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}\");\n        }\n\n        return value;\n    }\n    public static Int32 Range(\n        Int32 value,\n        [InvokerParameterName][NotNull] string parameterName,\n        Int32 minimumValue,\n        Int32 maximumValue = Int32.MaxValue)\n    {\n        if (value < minimumValue || value > maximumValue)\n        {\n            throw new ArgumentException($\"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}\");\n        }\n\n        return value;\n    }\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs#L248-L284","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nCheck.Range(priority, nameof(priority), (short)1, (short)10); // priority == 0 -> throws\n\n// after\nCheck.Range((short)Math.Clamp(priority, 1, 10), nameof(priority), (short)1, (short)10);","handlingStrategy":"validation","validationCode":"// Clamp Int16 into the accepted window before guarding\nshort safe = Math.Clamp(value, minimumValue, maximumValue);\nCheck.Range(safe, nameof(value), minimumValue, maximumValue);","typeGuard":"static bool InRangeShort(short v, short min, short max) => v >= min && v <= max;","tryCatchPattern":null,"preventionTips":["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)."],"tags":["argument-validation","numeric","int16","range","abp","guard-clause"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}