{"record":{"id":"0ba9bd3d26a56127","repo":"abpframework/abp","slug":"parametername-is-null","errorCode":null,"errorMessage":"{parameterName} is null!","messagePattern":"(.+?) is null!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Check.cs","lineNumber":350,"sourceCode":"        decimal minimumValue,\n        decimal maximumValue = decimal.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\n    public static T NotDefaultOrNull<T>(\n        [System.Diagnostics.CodeAnalysis.NotNull] T? value,\n        [InvokerParameterName][NotNull] string parameterName)\n        where T : struct\n    {\n        if (value == null)\n        {\n            throw new ArgumentException($\"{parameterName} is null!\", parameterName);\n        }\n\n        if (value.Value.Equals(default(T)))\n        {\n            throw new ArgumentException($\"{parameterName} has a default value!\", parameterName);\n        }\n\n        return value.Value;\n    }\n}\n","sourceCodeStart":332,"sourceCodeEnd":361,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs#L332-L361","documentation":"Thrown by Check.NotDefaultOrNull<T> when a nullable value type T? (where T : struct) argument is null. Unlike NotNull, this overload is for nullable structs and reports the first of two checks — null vs default(T). It is an ArgumentException carrying parameterName.","triggerScenarios":"Calling Check.NotDefaultOrNull(maybeStruct, nameof(maybeStruct)) where maybeStruct (e.g. Guid?, int?, DateTime?) is null.","commonSituations":"An optional identifier (Guid? tenantId) that was never set, a DTO property not supplied by the client, or a value read from a nullable DB column that came back DBNull.","solutions":["Supply a concrete value instead of null before calling NotDefaultOrNull.","If null is legitimately allowed, do not use NotDefaultOrNull — use plain null-tolerant logic or Check.NotNull on a reference.","Initialize the nullable to a real default (Guid.NewGuid(), DateTime.UtcNow) at construction.","Validate at the API boundary with [Required] so the caller is told which field is missing."],"exampleFix":"// before\nvar tenantId = Check.NotDefaultOrNull(input.TenantId, nameof(input.TenantId));\n\n// after\nif (input.TenantId is null)\n{\n    return BadRequest(\"TenantId is required.\");\n}\nvar tenantId = Check.NotDefaultOrNull(input.TenantId, nameof(input.TenantId));","handlingStrategy":"validation","validationCode":"static bool HasValue<T>(T? value) where T : struct => value is not null;\n\nif (!HasValue(input.TenantId)) return BadRequest(\"TenantId is required\");\nvar tenantId = Check.NotDefaultOrNull(input.TenantId, nameof(input.TenantId));","typeGuard":"static bool IsSet<T>(T? value) where T : struct => value.HasValue;\n// usage: if (IsSet(maybeGuid)) { /* safe to call NotDefaultOrNull next */ }","tryCatchPattern":"try\n{\n    var id = Check.NotDefaultOrNull(input.Id, nameof(input.Id));\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(input.Id))\n{\n    return NotFound(\"Id not supplied\");\n}","preventionTips":["Mark required nullable-struct DTO properties with [Required].","Initialize ids with Guid.NewGuid() at entity creation rather than leaving them null.","Distinguish 'not provided' (null) from 'default' (Guid.Empty) in your validation."],"tags":["validation","argument","nullable","check","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}