Dogfalo/materialize · error · Error
noUiSlider: 'start' option is incorrect.
Error message
noUiSlider: 'start' option is incorrect.
What it means
Thrown by testStart when, after asArray wrapping, the 'start' option is an empty array. start sets the initial handle positions and its length determines the handle count, so at least one value is required. Note the values themselves are not range-checked here (the .val method handles that), only the presence of entries.
Source
Thrown at extras/noUiSlider/nouislider.js:501
throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");
}
// Catch equal start or end.
if ( entry.min === entry.max ) {
throw new Error("noUiSlider: 'range' 'min' and 'max' cannot be equal.");
}
parsed.spectrum = new Spectrum(entry, parsed.snap, parsed.dir, parsed.singleStep);
}
function testStart ( parsed, entry ) {
entry = asArray(entry);
// Validate input. Values aren't tested, as the public .val method
// will always provide a valid location.
if ( !Array.isArray( entry ) || !entry.length ) {
throw new Error("noUiSlider: 'start' option is incorrect.");
}
// Store the number of handles.
parsed.handles = entry.length;
// When the slider is initialized, the .val method will
// be called with the start options.
parsed.start = entry;
}
function testSnap ( parsed, entry ) {
// Enforce 100% stepping within subranges.
parsed.snap = entry;
if ( typeof entry !== 'boolean' ){
throw new Error("noUiSlider: 'snap' option must be a boolean.");
}View on GitHub (pinned to 824e78248b)
Solutions
- Provide at least one start value within range.
- Defer noUiSlider.create until the start data is non-empty.
- Default to [min] (or another in-range value) when nothing is selected.
Example fix
// before start: selected // selected === [] // after start: selected.length ? selected : [min]
Defensive patterns
Strategy: validation
Validate before calling
const start = Array.isArray(opts.start) ? opts.start : [opts.start];
if (!start.length) throw new Error('start must contain at least one value');
opts.start = start; Type guard
function hasStart(s) { return (Array.isArray(s) ? s : [s]).length > 0; } Try / catch
try { noUiSlider.create(el, opts); }
catch (e) { if (/start' option is incorrect/.test(e.message)) { opts.start = [opts.range.min]; /* retry */ } else throw e; } Prevention
- Defer noUiSlider.create until selected values are loaded.
- Default to [min] when nothing is selected rather than passing an empty array.
- Filter the source list before, not inside, the config object.
When it happens
Trigger: start: [] is the direct trigger. Also reachable via code paths that filter a source list to zero elements before passing it.
Common situations: Initializing the slider before selected values arrive from an API, filtering the value list down to nothing, or passing a computed array that is empty under some condition.
Related errors
- noUiSlider: 'range' contains invalid value.
- noUiSlider: 'range' value isn't numeric.
- noUiSlider: 'limit', 'margin' and 'padding' must be divisibl
- noUiSlider: 'step' is not numeric.
- noUiSlider: 'range' is not an object.
AI-assisted analysis of Dogfalo/materialize@824e78248b (2026-08-13).
Data as JSON: /api/errors/787d6b01a8b7f868.
Report an issue: GitHub.