Skip to main content

Function: sanitiseColourPalettes()

sanitiseColourPalettes(input, author?): ColourPalette[] | undefined

Defined in: src/lib/classes/ColourPalettes/index.ts:51

Keep only valid palettes from an untrusted value (e.g. stored or imported): each with a UUID, a name and valid colours (see sanitisePalette), each ID once, up to MAX_SAVED_PALETTES. Palettes of version 1 are upgraded (see upgradeAsset). An invalid author is replaced with author, and an invalid group or version is left out. Undefined if the value isn't an array.

Parameters​

input​

unknown

author?​

AssetAuthor = UNKNOWN_AUTHOR

the author of palettes with none or an invalid one

Returns​

ColourPalette[] | undefined

Example​

sanitiseColourPalettes([{ "@type": "PaintCanvas/ColourPalette", id: crypto.randomUUID(), name: "Sunset",
author: "Ada", content: { colours: ["#FF0000", "red"] } }]); // colours ["#ff0000"]