{"record":{"id":"ee69b50b4902c66d","repo":"Dogfalo/materialize","slug":"nouislider-tooltips-must-be-passed-a-formatter","errorCode":null,"errorMessage":"noUiSlider: 'tooltips' must be passed a formatter or 'false'.","messagePattern":"noUiSlider: 'tooltips' must be passed a formatter or 'false'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":725,"sourceCode":"\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        }\n\n        throw new Error(\"noUiSlider: 'format' requires 'to' and 'from' methods.\");\n    }\n\n    function testCssPrefix ( parsed, entry ) {","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L707-L743","documentation":"Each element of the tooltips array must be either a boolean (true shows a default tooltip, false hides it) or an object exposing a .to(value) formatter function. The library rejects anything else so that rendering never receives an uncallable value.","triggerScenarios":"Pass tooltips as an array containing a string, number, null, or an object without a .to function. For example tooltips:['%'], tooltips:[null], or tooltips:[{ format: x => x }].","commonSituations":"Developers pass a CSS/label string instead of a formatter object, pass a wNumb formatter whose .to was renamed, or pass null expecting it to mean 'hidden' (use false instead).","solutions":["Use false to hide a tooltip and true for the default.","Provide a formatter object with a to function: wNumb({ decimals: 0, prefix: '$' }) or { to: v => v + '%' }.","Replace null entries with false."],"exampleFix":"// before\nnoUiSlider.create(el, { start: [0], range:{min:0,max:100}, tooltips: ['%'] });\n// after\nnoUiSlider.create(el, { start: [0], range:{min:0,max:100}, tooltips: [{ to: v => v + '%' }] });","handlingStrategy":"type-guard","validationCode":"function normalizeTooltips(opts) {\n  const handles = Array.isArray(opts.start) ? opts.start.length : 1;\n  if (opts.tooltips == null) return Array(handles).fill(true);\n  return (Array.isArray(opts.tooltips) ? opts.tooltips : [opts.tooltips]).map(t => {\n    if (t === false || t === true) return t;\n    if (t && typeof t.to === 'function') return t;\n    throw new TypeError('each tooltip must be boolean or { to: fn }');\n  });\n}","typeGuard":"function isTooltipEntry(t) {\n  return typeof t === 'boolean' || (typeof t === 'object' && t !== null && typeof t.to === 'function');\n}","tryCatchPattern":null,"preventionTips":["Use false (not null) to hide a tooltip.","Use wNumb for formatted tooltips so both to/from exist.","Validate each array entry before passing to noUiSlider."],"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"}