{"record":{"id":"c7ff1e24a8008439","repo":"Dogfalo/materialize","slug":"nouislider-behaviour-must-be-a-string-containin","errorCode":null,"errorMessage":"noUiSlider: 'behaviour' must be a string containing options.","messagePattern":"noUiSlider: 'behaviour' must be a string containing options\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":670,"sourceCode":"        // Invert connection for RTL sliders, so that the proper\n        // handles get the connect/background classes.\n        switch ( entry ) {\n            case 'ltr':\n                parsed.dir = 0;\n                break;\n            case 'rtl':\n                parsed.dir = 1;\n                break;\n            default:\n                throw new Error(\"noUiSlider: 'direction' option was not recognized.\");\n        }\n    }\n\n    function testBehaviour ( parsed, entry ) {\n\n        // Make sure the input is a string.\n        if ( typeof entry !== 'string' ) {\n            throw new Error(\"noUiSlider: 'behaviour' must be a string containing options.\");\n        }\n\n        // Check if the string contains any keywords.\n        // None are required.\n        var tap = entry.indexOf('tap') >= 0;\n        var drag = entry.indexOf('drag') >= 0;\n        var fixed = entry.indexOf('fixed') >= 0;\n        var snap = entry.indexOf('snap') >= 0;\n        var hover = entry.indexOf('hover') >= 0;\n\n        if ( fixed ) {\n\n            if ( parsed.handles !== 2 ) {\n                throw new Error(\"noUiSlider: 'fixed' behaviour must be used with 2 handles\");\n            }\n\n            // Use margin to enforce fixed state\n            testMargin(parsed, parsed.start[1] - parsed.start[0]);","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L652-L688","documentation":"noUiSlider requires the 'behaviour' option to be a string of space-or-comma separated keywords (tap, drag, fixed, snap, hover). The guard rejects any non-string before parsing keywords, because indexOf would otherwise throw or misbehave.","triggerScenarios":"Call noUiSlider.create() with options.behaviour that is not a string: a boolean true, an array ['tap','drag'], an object, undefined-coerced, or null.","commonSituations":"Developers pass an array thinking behaviour accepts multiple flags as a list, or pass true/false expecting a boolean toggle. Also happens when behaviour is loaded from JSON where it was serialized as an array.","solutions":["Pass behaviour as a single string containing the desired flags, e.g. 'tap drag' or 'drag-tap'.","If you have an array of flags, join them: behaviour: flags.join(' ').","Omit behaviour to use the default, or set it to an empty string '' if no flags are wanted."],"exampleFix":"// before\nnoUiSlider.create(el, { start: 0, range:{min:0,max:100}, behaviour: ['tap','drag'] });\n// after\nnoUiSlider.create(el, { start: 0, range:{min:0,max:100}, behaviour: 'tap drag' });","handlingStrategy":"validation","validationCode":"function normalizeBehaviour(raw) {\n  if (Array.isArray(raw)) return raw.join(' ');\n  if (typeof raw !== 'string') throw new TypeError('behaviour must be a string');\n  return raw;\n}","typeGuard":"function isValidBehaviour(v) { return typeof v === 'string'; }","tryCatchPattern":null,"preventionTips":["Treat behaviour as a single space-separated string, not an array.","If accepting user input, validate with typeof === 'string' before create().","Document the allowed keywords (tap, drag, fixed, snap, hover) next to the config."],"tags":["nouislider","validation","configuration","type-error"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}