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

  1. Provide at least one start value within range.
  2. Defer noUiSlider.create until the start data is non-empty.
  3. 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

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


AI-assisted analysis of Dogfalo/materialize@824e78248b (2026-08-13). Data as JSON: /api/errors/787d6b01a8b7f868. Report an issue: GitHub.