{"record":{"id":"8654ed7fcd0e06ad","repo":"Dogfalo/materialize","slug":"nouislider-range-contains-invalid-value","errorCode":null,"errorMessage":"noUiSlider: 'range' contains invalid value.","messagePattern":"noUiSlider: 'range' contains invalid value\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":289,"sourceCode":"                xSteps[j-1]\n            );\n    }\n\n\n// Entry parsing\n\n    function handleEntryPoint ( index, value, that ) {\n\n        var percentage;\n\n        // Wrap numerical input in an array.\n        if ( typeof value === \"number\" ) {\n            value = [value];\n        }\n\n        // Reject any invalid input, by testing whether value is an array.\n        if ( Object.prototype.toString.call( value ) !== '[object Array]' ){\n            throw new Error(\"noUiSlider: 'range' contains invalid value.\");\n        }\n\n        // Covert min/max syntax to 0 and 100.\n        if ( index === 'min' ) {\n            percentage = 0;\n        } else if ( index === 'max' ) {\n            percentage = 100;\n        } else {\n            percentage = parseFloat( index );\n        }\n\n        // Check for correct input.\n        if ( !isNumeric( percentage ) || !isNumeric( value[0] ) ) {\n            throw new Error(\"noUiSlider: 'range' value isn't numeric.\");\n        }\n\n        // Store values.\n        that.xPct.push( percentage );","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L271-L307","documentation":"Thrown by handleEntryPoint while parsing each entry of the 'range' option. After wrapping a number into an array, the code requires the value to be an array; anything that is neither a number nor an array (string, null, boolean, plain object) is rejected before any percentage conversion happens. noUiSlider expects each range value to be a number like 100 or a [value, step] pair, so structurally wrong inputs fail fast here rather than producing a broken scale.","triggerScenarios":"range: { min: \"0\", max: 100 } (string value), range: { min: null, max: 100 }, range: { min: true, max: 100 }, or range: { min: { v: 0 }, max: 100 } (object literal as a value).","commonSituations":"Reading min/max from DOM data attributes (always strings), from a JSON endpoint that quoted the numbers, or pasting config from docs whose formatting turned numbers into strings. Also happens when a value field is conditionally set and left null/undefined.","solutions":["Pass real numbers: range: { min: 0, max: 100 }.","If sourcing from DOM/JSON, coerce with Number(raw) and verify !isNaN before building the slider.","For a per-stop step use the array form [value, step] with numeric elements, e.g. { '50%': [50, 10] }."],"exampleFix":"// before\nrange: { min: \"0\", max: \"100\" }\n// after\nrange: { min: Number(rawMin), max: Number(rawMax) }","handlingStrategy":"validation","validationCode":"function assertRangeValuesNumeric(range) {\n  for (const key of Object.keys(range)) {\n    const v = range[key];\n    const val = typeof v === 'number' ? v : (Array.isArray(v) ? v[0] : undefined);\n    if (typeof val !== 'number' || !Number.isFinite(val)) {\n      throw new TypeError(\"range['\" + key + \"'] must be a number or [number, step]\");\n    }\n  }\n}\nassertRangeValuesNumeric(opts.range);","typeGuard":"function isRangeValue(v) {\n  return typeof v === 'number' || (Array.isArray(v) && typeof v[0] === 'number');\n}","tryCatchPattern":"try { noUiSlider.create(el, opts); }\ncatch (e) {\n  if (/range' contains invalid value/.test(e.message)) { /* coerce range values to numbers and retry once */ }\n  else throw e;\n}","preventionTips":["Never feed dataset attributes or JSON strings straight into range; coerce with Number() first.","Keep a single typed config builder so all numeric options pass through one coercion path.","Add a unit test that constructs the slider with your production config shape."],"tags":["config","validation","range","type-coercion","initialization"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}