{"record":{"id":"f18cfc5328ffa7ad","repo":"Dogfalo/materialize","slug":"nouislider-padding-option-must-be-a-positive-nu","errorCode":null,"errorMessage":"noUiSlider: 'padding' option must be a positive number.","messagePattern":"noUiSlider: 'padding' option must be a positive number\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":641,"sourceCode":"\n    function testPadding ( parsed, entry ) {\n\n        if ( !isNumeric(entry) ){\n            throw new Error(\"noUiSlider: 'padding' option must be numeric.\");\n        }\n\n        if ( entry === 0 ) {\n            return;\n        }\n\n        parsed.padding = parsed.spectrum.getMargin(entry);\n\n        if ( !parsed.padding ) {\n            throw new Error(\"noUiSlider: 'padding' option is only supported on linear sliders.\");\n        }\n\n        if ( parsed.padding < 0 ) {\n            throw new Error(\"noUiSlider: 'padding' option must be a positive number.\");\n        }\n\n        if ( parsed.padding >= 50 ) {\n            throw new Error(\"noUiSlider: 'padding' option must be less than half the range.\");\n        }\n    }\n\n    function testDirection ( parsed, entry ) {\n\n        // Set direction as a numerical value for easy parsing.\n        // Invert connection for RTL sliders, so that the proper\n        // handles get the connect/background classes.\n        switch ( entry ) {\n            case 'ltr':\n                parsed.dir = 0;\n                break;\n            case 'rtl':\n                parsed.dir = 1;","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L623-L659","documentation":"Thrown by testPadding when parsed.padding < 0, after getMargin converted the input to a percentage. padding must shrink the selectable region, so a negative input (which would expand it) is rejected. This check runs only after the linear-range check passes, so it is reached solely on linear sliders with a numeric padding.","triggerScenarios":"padding: -10, a computed padding that goes negative, or padding: -0.0001 from rounding error.","commonSituations":"Subtracting a margin from a base value and going negative, a sign error in computation, or feeding an unclamped user input straight through.","solutions":["Pass a non-negative number: padding: 10.","Clamp the computed value: Math.max(0, value).","Use 0 (or omit padding) to disable."],"exampleFix":"// before\npadding: -5\n// after\npadding: Math.max(0, p)","handlingStrategy":"validation","validationCode":"if (opts.padding != null && opts.padding < 0) {\n  throw new Error('padding must be non-negative');\n}\n// or clamp: opts.padding = Math.max(0, Number(opts.padding));","typeGuard":null,"tryCatchPattern":"try { noUiSlider.create(el, opts); }\ncatch (e) { if (/padding' option must be a positive number/.test(e.message)) { opts.padding = Math.abs(opts.padding); /* retry */ } else throw e; }","preventionTips":["Clamp computed padding with Math.max(0, value) before passing it in.","Validate sign at the config boundary, especially for derived values.","Treat negative padding as a bug in the upstream calculation, not a feature."],"tags":["config","validation","padding","positive"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}