Dogfalo/materialize · error · Error

noUiSlider: Missing 'min' or 'max' in 'range'.

Error message

noUiSlider: Missing 'min' or 'max' in 'range'.

What it means

Thrown by testRange after the object check passes but entry.min or entry.max is undefined. Both endpoints are mandatory: 'min' maps to the 0% position and 'max' to the 100% position of the slider scale. Without them the spectrum cannot be constructed.

Source

Thrown at extras/noUiSlider/nouislider.js:483

        if ( !isNumeric( entry ) ) {
            throw new Error("noUiSlider: 'step' is not numeric.");
        }

        // The step option can still be used to set stepping
        // for linear sliders. Overwritten if set in 'range'.
        parsed.singleStep = entry;
    }

    function testRange ( parsed, entry ) {

        // Filter incorrect input.
        if ( typeof entry !== 'object' || Array.isArray(entry) ) {
            throw new Error("noUiSlider: 'range' is not an object.");
        }

        // Catch missing start or end.
        if ( entry.min === undefined || entry.max === undefined ) {
            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.");

View on GitHub (pinned to 824e78248b)

Solutions

  1. Always include both min and max.
  2. Guard upstream: if (min == null || max == null) throw new Error('bounds required').
  3. Fall back to sane defaults before constructing the slider.

Example fix

// before
range: { min: 0 }
// after
range: { min: 0, max: 100 }
Defensive patterns

Strategy: validation

Validate before calling

if (opts.range.min == null || opts.range.max == null) {
  throw new Error("range must define both 'min' and 'max'");
}

Type guard

function hasMinMax(r) { return r != null && r.min != null && r.max != null; }

Try / catch

try { noUiSlider.create(el, opts); }
catch (e) { if (/Missing 'min' or 'max'/.test(e.message)) { /* supply the missing bound */ } else throw e; }

Prevention

When it happens

Trigger: range: { min: 0 }, range: { max: 100 }, range: { '50%': 50 } (no endpoints), or range: { min: 0, max: undefined }.

Common situations: Building range from partial data where one bound is missing, typoing a key (e.g. 'Max'), or a conditional spread that drops a key when a value is falsy.

Related errors


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