{"record":{"id":"b6599bbd6637920d","repo":"Dogfalo/materialize","slug":"nouislider-snap-option-must-be-a-boolean","errorCode":null,"errorMessage":"noUiSlider: 'snap' option must be a boolean.","messagePattern":"noUiSlider: 'snap' option must be a boolean\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":518,"sourceCode":"        if ( !Array.isArray( entry ) || !entry.length ) {\n            throw new Error(\"noUiSlider: 'start' option is incorrect.\");\n        }\n\n        // Store the number of handles.\n        parsed.handles = entry.length;\n\n        // When the slider is initialized, the .val method will\n        // be called with the start options.\n        parsed.start = entry;\n    }\n\n    function testSnap ( parsed, entry ) {\n\n        // Enforce 100% stepping within subranges.\n        parsed.snap = entry;\n\n        if ( typeof entry !== 'boolean' ){\n            throw new Error(\"noUiSlider: 'snap' option must be a boolean.\");\n        }\n    }\n\n    function testAnimate ( parsed, entry ) {\n\n        // Enforce 100% stepping within subranges.\n        parsed.animate = entry;\n\n        if ( typeof entry !== 'boolean' ){\n            throw new Error(\"noUiSlider: 'animate' option must be a boolean.\");\n        }\n    }\n\n    function testAnimationDuration ( parsed, entry ) {\n\n        parsed.animationDuration = entry;\n\n        if ( typeof entry !== 'number' ){","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L500-L536","documentation":"Thrown by testSnap when 'snap' is not typeof === 'boolean'. snap forces handles onto the nearest step; the library refuses truthy/falsy coercions like 1/0 or the strings 'true'/'false'. Note the value is assigned to parsed.snap before the type check, but the throw still aborts initialization.","triggerScenarios":"snap: 1, snap: 0, snap: 'true', or snap: 'false' (both strings are truthy and would also behave wrong if accepted).","commonSituations":"Reading snap from a checkbox's value attribute or dataset (always a string), from JSON like {\"snap\": 1}, or toggling it with a numeric flag.","solutions":["Use the literal true or false.","Coerce explicitly: snap: raw === true || raw === 'true'.","Omit snap to keep the default (false)."],"exampleFix":"// before\nsnap: el.dataset.snap\n// after\nsnap: el.dataset.snap === 'true'","handlingStrategy":"type-guard","validationCode":"if (opts.snap != null && typeof opts.snap !== 'boolean') {\n  throw new TypeError('snap must be a boolean');\n}","typeGuard":"function isBoolean(v) { return typeof v === 'boolean'; }","tryCatchPattern":"try { noUiSlider.create(el, opts); }\ncatch (e) { if (/snap' option must be a boolean/.test(e.message)) { opts.snap = Boolean(opts.snap); /* retry */ } else throw e; }","preventionTips":["Bind checkboxes to their checked property, not their string value attribute.","Coerce dataset strings: snap: raw === 'true'.","Type the option as boolean in your config interface."],"tags":["config","validation","snap","boolean"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}