{"record":{"id":"a79337d4cf877848","repo":"Dogfalo/materialize","slug":"nouislider-margin-option-is-only-supported-on-l","errorCode":null,"errorMessage":"noUiSlider: 'margin' option is only supported on linear sliders.","messagePattern":"noUiSlider: 'margin' option is only supported on linear sliders\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":607,"sourceCode":"                throw new Error(\"noUiSlider: 'orientation' option is invalid.\");\n        }\n    }\n\n    function testMargin ( parsed, entry ) {\n\n        if ( !isNumeric(entry) ){\n            throw new Error(\"noUiSlider: 'margin' option must be numeric.\");\n        }\n\n        // Issue #582\n        if ( entry === 0 ) {\n            return;\n        }\n\n        parsed.margin = parsed.spectrum.getMargin(entry);\n\n        if ( !parsed.margin ) {\n            throw new Error(\"noUiSlider: 'margin' option is only supported on linear sliders.\");\n        }\n    }\n\n    function testLimit ( parsed, entry ) {\n\n        if ( !isNumeric(entry) ){\n            throw new Error(\"noUiSlider: 'limit' option must be numeric.\");\n        }\n\n        parsed.limit = parsed.spectrum.getMargin(entry);\n\n        if ( !parsed.limit || parsed.handles < 2 ) {\n            throw new Error(\"noUiSlider: 'limit' option is only supported on linear sliders with 2 or more handles.\");\n        }\n    }\n\n    function testPadding ( parsed, entry ) {\n","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L589-L625","documentation":"Thrown by testMargin when Spectrum.getMargin returns false. getMargin returns false whenever the spectrum has more than two points (xPct.length !== 2), i.e. the range contains intermediate stops and is therefore non-linear. margin/limit/padding are only computable on a single linear segment, so a stepped scale cannot honor them.","triggerScenarios":"range: { min: 0, '50%': 50, max: 100 } combined with margin: 10. Three spectrum points make getMargin return false.","commonSituations":"Adding an intermediate stop for a non-linear scale while keeping an existing margin config, or reusing a margin value from a linear slider on a stepped scale.","solutions":["Remove margin when the range has intermediate stops.","Use a purely linear range: { min, max } if you need margin.","Enforce handle separation manually in the change/update event handlers."],"exampleFix":"// before\nrange: { min: 0, '50%': 50, max: 100 }, margin: 10\n// after\nrange: { min: 0, max: 100 }, margin: 10","handlingStrategy":"validation","validationCode":"function isLinearRange(range) { return Object.keys(range).length === 2 && 'min' in range && 'max' in range; }\nif (opts.margin != null && !isLinearRange(opts.range)) {\n  throw new Error('margin requires a linear range ({ min, max } only)');\n}","typeGuard":null,"tryCatchPattern":"try { noUiSlider.create(el, opts); }\ncatch (e) { if (/margin' option is only supported on linear/.test(e.message)) { delete opts.margin; /* retry */ } else throw e; }","preventionTips":["Keep margin exclusive to linear-range sliders.","When you add an intermediate stop, drop margin/limit/padding.","Enforce handle separation in event handlers for non-linear scales."],"tags":["config","validation","margin","linear-range"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}