{"record":{"id":"a66ec81822eac25c","repo":"stride3d/stride","slug":"paramname-doesn-t-meet-the-condition","errorCode":null,"errorMessage":"{paramName} doesn't meet the condition.","messagePattern":"(.+?) doesn't meet the condition\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs","lineNumber":60,"sourceCode":"        /// </summary>\n        /// <typeparam name=\"T\">The type of the <paramref name=\"variable\"/>.</typeparam>\n        /// <param name=\"variable\">The value to check.</param>\n        /// <param name=\"predicate\">The predicate that implements the condition.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentException\">\n        /// <paramref name=\"variable\"/> doesn't meet the <paramref name=\"predicate\"/>.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void Condition<T>(T variable, Predicate<T> predicate, string variableName)\n        {\n            var paramName = variableName ?? \"The variable\";\n            // Variable and predicate cannot be null\n            NotNull(variable, paramName);\n            NotNull(predicate, \"predicate\");\n\n            if (!predicate.Invoke(variable))\n            {\n                throw new ArgumentException($\"{paramName} doesn't meet the condition.\");\n            }\n        }\n\n        /// <summary>\n        /// Checks wether the <paramref name=\"collection\"/> is not empty.\n        /// Otherwise throws an exception.\n        /// </summary>\n        /// <param name=\"collection\">The collection to check.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentNullException\">\n        /// The <paramref name=\"collection\"/> cannot be <see langword=\"null\"/>.\n        /// </exception>\n        /// <exception cref=\"ArgumentOutOfRangeException\">\n        /// The <paramref name=\"collection\"/> is empty.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotEmpty(ICollection collection, string variableName)\n        {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs#L42-L78","documentation":"Stride.Core.Assets.Editor.ArgumentCheck.Condition validates that a non-null variable satisfies a caller-supplied predicate; if predicate.Invoke(variable) returns false it throws ArgumentException with the message \"{paramName} doesn't meet the condition.\" It is a general-purpose contract helper, so this error means an argument passed an API's stated condition check but failed it.","triggerScenarios":"Calling any API that guards its parameters with ArgumentCheck.Condition (directly or via ArgumentNotNullAndCondition-style helpers) and passing a value for which the required predicate returns false, e.g. a non-positive number where positivity is required, or a string failing a format predicate.","commonSituations":"Passing default(T) numeric values (0) into APIs requiring positive counts; passing paths/identifiers that fail pattern checks; constructing asset objects programmatically with values that the interactive editor would have validated up front; after refactors changed a predicate without updating call sites.","solutions":["Read the calling API's source/contract to learn the exact predicate and validate the value before passing it.","Check the paramName in the exception message — it names the offending argument directly.","Pre-validate the value with the same condition and fail early with a descriptive message.","For default-initialized values (0, empty), initialize the argument to a valid value before the call."],"exampleFix":"// before\nbuilder.SetCapacity(count); // count == 0 fails Condition(count, c => c > 0)\n// after\nif (count <= 0)\n    throw new ArgumentException(\"Capacity must be positive\", nameof(count));\nbuilder.SetCapacity(count);","handlingStrategy":"validation","validationCode":"if (value <= 0) throw new ArgumentException(\"must be positive\", nameof(value));\napiCall(value);","typeGuard":null,"tryCatchPattern":"try\n{\n    apiCall(arg);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"doesn't meet the condition\"))\n{\n    logger.LogError(ex, \"Argument {Param} violated condition\", ex.ParamName);\n    throw;\n}","preventionTips":["Run the same predicate locally before calling APIs guarded by ArgumentCheck.","Never pass default-initialized values (0, empty string) into contract-checked parameters.","Include paramName in your own diagnostics to speed triage."],"tags":["argument-validation","contract-check","precondition-failed"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}