{"record":{"id":"03950f078b01829f","repo":"abpframework/abp","slug":"parametername-can-not-be-null-or-empty","errorCode":null,"errorMessage":"{parameterName} can not be null or empty!","messagePattern":"(.+?) can not be null or empty!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Check.cs","lineNumber":97,"sourceCode":"\n        if (minLength > 0 && value!.Length < minLength)\n        {\n            throw new ArgumentException($\"{parameterName} length must be equal to or bigger than {minLength}!\", parameterName);\n        }\n\n        return value;\n    }\n\n    [ContractAnnotation(\"value:null => halt\")]\n    public static string NotNullOrEmpty(\n        [System.Diagnostics.CodeAnalysis.NotNull] string? value,\n        [InvokerParameterName][NotNull] string parameterName,\n        int maxLength = int.MaxValue,\n        int minLength = 0)\n    {\n        if (value.IsNullOrEmpty())\n        {\n            throw new ArgumentException($\"{parameterName} can not be null or empty!\", parameterName);\n        }\n\n        if (value!.Length > maxLength)\n        {\n            throw new ArgumentException($\"{parameterName} length must be equal to or lower than {maxLength}!\", parameterName);\n        }\n\n        if (minLength > 0 && value!.Length < minLength)\n        {\n            throw new ArgumentException($\"{parameterName} length must be equal to or bigger than {minLength}!\", parameterName);\n        }\n\n        return value;\n    }\n\n    [ContractAnnotation(\"value:null => halt\")]\n    public static ICollection<T> NotNullOrEmpty<T>(\n        [System.Diagnostics.CodeAnalysis.NotNull] ICollection<T>? value,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs#L79-L115","documentation":"Check.NotNullOrEmpty(string) rejects null or empty (\"\") strings using IsNullOrEmpty() but ALLOWS whitespace-only values (less strict than NotNullOrWhiteSpace). After the emptiness check it applies optional maxLength/minLength bounds. Choose this when a literal empty is invalid but whitespace is acceptable.","triggerScenarios":"Check.NotNullOrEmpty(\"\", nameof(x)) or null; an ABP API that requires a non-empty value receiving an empty string.","commonSituations":"An identifier that may be \" \" but not \"\"; config values that must be set (non-empty) but where whitespace is tolerated; mis-pick of validator (should have used NotNullOrWhiteSpace).","solutions":["Pass a non-null, non-empty string.","If whitespace should also fail, switch to Check.NotNullOrWhiteSpace instead.","Default-fall to a real value at the caller if empty is a legitimate 'unset' state."],"exampleFix":"// before\nCheck.NotNullOrEmpty(\"\", nameof(x)); // throws\n\n// after\nCheck.NotNullOrEmpty(value ?? \"default\", nameof(x));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(value))\n    value = fallback;\nCheck.NotNullOrEmpty(value, nameof(value));","typeGuard":"bool IsNonEmpty(string? s) => !string.IsNullOrEmpty(s);","tryCatchPattern":null,"preventionTips":["Resolve empty/null to a default at the caller before guarded APIs.","Choose NotNullOrWhiteSpace instead when whitespace must also fail.","Use [Required] on DTO properties so model binding rejects empty before your code runs."],"tags":["validation","argument","empty-check"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}