{"record":{"id":"a32cb51bb38f23f3","repo":"Dogfalo/materialize","slug":"nouislider-margin-option-must-be-numeric","errorCode":null,"errorMessage":"noUiSlider: 'margin' option must be numeric.","messagePattern":"noUiSlider: 'margin' option must be numeric\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":596,"sourceCode":"\n        // Set orientation to an a numerical value for easy\n        // array selection.\n        switch ( entry ){\n            case 'horizontal':\n                parsed.ort = 0;\n                break;\n            case 'vertical':\n                parsed.ort = 1;\n                break;\n            default:\n                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.\");","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L578-L614","documentation":"Thrown by testMargin when 'margin' fails isNumeric. margin is the minimum enforced distance between handles and must be a real finite number; numeric strings, null, and unit-suffixed values are rejected (isNumeric checks typeof === 'number').","triggerScenarios":"margin: '10', margin: null, margin: '10px', margin: NaN.","commonSituations":"String value from a DOM attribute or JSON, a CSS-style value carrying a unit suffix, or null used to mean 'disabled'.","solutions":["Pass a number: margin: 10.","Coerce strings with Number(raw) after an isFinite check.","Use 0 (or omit margin) to disable the constraint."],"exampleFix":"// before\nmargin: \"20\"\n// after\nmargin: 20","handlingStrategy":"validation","validationCode":"if (opts.margin != null) {\n  const m = Number(opts.margin);\n  if (typeof opts.margin !== 'number' || !Number.isFinite(m)) throw new TypeError('margin must be a number');\n  opts.margin = m;\n}","typeGuard":"function isMargin(v) { return typeof v === 'number' && Number.isFinite(v); }","tryCatchPattern":"try { noUiSlider.create(el, opts); }\ncatch (e) { if (/margin' option must be numeric/.test(e.message)) { opts.margin = Number(opts.margin); /* retry */ } else throw e; }","preventionTips":["Coerce string sources with Number() before assignment.","Strip unit suffixes at the boundary.","Use 0 (or omit) to disable margin instead of null."],"tags":["config","validation","margin","type-coercion"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}