{"record":{"id":"768ed8401c427a22","repo":"Dogfalo/materialize","slug":"nouislider-must-pass-a-formatter-for-all-handles","errorCode":null,"errorMessage":"noUiSlider: must pass a formatter for all handles.","messagePattern":"noUiSlider: must pass a formatter for all handles\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":720,"sourceCode":"        if ( entry === false ) {\n            return;\n        }\n\n        else if ( entry === true ) {\n\n            parsed.tooltips = [];\n\n            for ( var i = 0; i < parsed.handles; i++ ) {\n                parsed.tooltips.push(true);\n            }\n        }\n\n        else {\n\n            parsed.tooltips = asArray(entry);\n\n            if ( parsed.tooltips.length !== parsed.handles ) {\n                throw new Error(\"noUiSlider: must pass a formatter for all handles.\");\n            }\n\n            parsed.tooltips.forEach(function(formatter){\n                if ( typeof formatter !== 'boolean' && (typeof formatter !== 'object' || typeof formatter.to !== 'function') ) {\n                    throw new Error(\"noUiSlider: 'tooltips' must be passed a formatter or 'false'.\");\n                }\n            });\n        }\n    }\n\n    function testFormat ( parsed, entry ) {\n\n        parsed.format = entry;\n\n        // Any object with a to and from method is supported.\n        if ( typeof entry.to === 'function' && typeof entry.from === 'function' ) {\n            return true;\n        }","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L702-L738","documentation":"When 'tooltips' is not a boolean it is treated as a per-handle array via asArray(entry). noUiSlider requires one tooltip entry per handle, so a length mismatch throws before any tooltip is rendered.","triggerScenarios":"Call noUiSlider.create() with options.tooltips as an array whose length differs from options.start.length. E.g. start:[0,50,100] with tooltips:[true, false], or start:[0,50] with tooltips:[true,false,true].","commonSituations":"Adding/removing a handle but forgetting to update tooltips; passing a single-element array for a multi-handle slider; or assuming tooltips auto-expands like a boolean default.","solutions":["Make the tooltips array length exactly equal to start.length.","For all-on or all-off, pass a plain boolean (true/false) instead of an array so the library expands it per handle.","If only some handles need tooltips, build the array programmatically from start.length."],"exampleFix":"// before\nnoUiSlider.create(el, { start: [0, 50, 100], range:{min:0,max:100}, tooltips: [true, false] });\n// after\nnoUiSlider.create(el, { start: [0, 50, 100], range:{min:0,max:100}, tooltips: [true, false, true] });","handlingStrategy":"validation","validationCode":"function assertTooltipsMatch(opts) {\n  const handles = Array.isArray(opts.start) ? opts.start.length : 1;\n  if (Array.isArray(opts.tooltips) && opts.tooltips.length !== handles) {\n    throw new Error(`tooltips length ${opts.tooltips.length} !== handles ${handles}`);\n  }\n}","typeGuard":"function tooltipsMatchHandles(opts) {\n  const handles = Array.isArray(opts.start) ? opts.start.length : 1;\n  return !Array.isArray(opts.tooltips) || opts.tooltips.length === handles;\n}","tryCatchPattern":null,"preventionTips":["Prefer a plain boolean for tooltips unless per-handle control is required.","Derive the tooltips array from start.length programmatically.","Recount tooltips whenever you add or remove a handle."],"tags":["nouislider","validation","configuration","tooltips"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}