{"record":{"id":"a46ffb5c4eb59c8d","repo":"gchq/CyberChef","slug":"this-name-must-be-less-than-or-equal-to-this","errorCode":null,"errorMessage":"${this.name} must be less than or equal to ${this.max}.","messagePattern":"(.+?) must be less than or equal to (.+?)\\.","errorType":"validation","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/Ingredient.mjs","lineNumber":139,"sourceCode":"            }\n            if (checkVal instanceof Uint8Array && checkVal.length > this.maxLength) {\n                throw new OperationError(`${this.name} length cannot exceed ${this.maxLength}.`);\n            }\n        }\n\n        // 3. number checks\n        if (this.type === \"number\") {\n            if (checkVal === null || checkVal === undefined || isNaN(checkVal)) {\n                throw new OperationError(`${this.name} must be a number.`);\n            }\n            if (this.integer && !Number.isInteger(checkVal)) {\n                throw new OperationError(`${this.name} must be an integer.`);\n            }\n            if (typeof this.min === \"number\" && checkVal < this.min) {\n                throw new OperationError(`${this.name} must be greater than or equal to ${this.min}.`);\n            }\n            if (typeof this.max === \"number\" && checkVal > this.max) {\n                throw new OperationError(`${this.name} must be less than or equal to ${this.max}.`);\n            }\n        }\n\n        // 4. option checks\n        if (this.type === \"option\") {\n            if (Array.isArray(this.defaultValue)) {\n                const permittedOptions = this.defaultValue.filter(opt => {\n                    if (typeof opt !== \"string\") return false;\n                    return !opt.match(/^\\[\\/?[a-z0-9 -()^]+\\]$/i);\n                });\n                const valStr = (checkVal !== null && checkVal !== undefined) ? String(checkVal).toLowerCase() : \"\";\n                const matchedOption = permittedOptions.find(opt => opt.toLowerCase() === valStr);\n                if (!matchedOption) {\n                    throw new OperationError(`${this.name} must be one of the following: ${permittedOptions.join(\", \")}.`);\n                }\n            }\n        }\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/Ingredient.mjs#L121-L157","documentation":"Thrown by Ingredient.validate() when type is 'number', the value is a valid number, but it exceeds the ingredient's configured max (line 139). max is an optional numeric ceiling declared in the ingredient config.","triggerScenarios":"A numeric ingredient with max:N receives a value strictly greater than N; e.g. an offset ingredient with max:1023 gets 2000.","commonSituations":"User enters a too-large value for length/rounds/offset; programmatic recipe generation overshoots; an operation tightened its max in a newer version.","solutions":["Lower the value to at most max.","If the ceiling is wrong, raise max in the ingredient config and re-verify.","Clamp with Math.min(max, value) before assigning."],"exampleFix":"// before - max is 1023\nop.ingValues = [2000];\n\n// after\nop.ingValues = [1023];","handlingStrategy":"validation","validationCode":"if (typeof max === 'number' && val > max) throw new Error(`${name} > max ${max}`);","typeGuard":"function atOrBelowMax(v, max): v is number { return typeof v === 'number' && (max == null || v <= max); }","tryCatchPattern":"try { op.ingValues = [val]; } catch (e) { if (/less than or equal to/.test(e.message)) { val = max; } }","preventionTips":["Clamp with Math.min(max, val) before assigning.","Surface max as an input bound in the UI.","Re-check max after operation config changes."],"tags":["ingredient","validation","range","number","operationerror"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}