I would tighten the conditions on your asserts: rather than just asserting the variable (i.e. for nil or false), do assert(type(var) == “string”, “Message”), in fromString and fromHex , and assert(type(var) == “number”, “MESSAGE”) or assert(tonumber(var), “MESSAGE”) in fromRGB.
In the line
code = code and string.gsub( code , "#", "") or "FFFFFFFF"
the “code and” part is unnecessary since you’ve already done the assert. Also,
local color = colorString
doesn’t seem to get you much (I’d just call the parameter itself color; implicitly, it’s already a string according to the function name).
The color table itself should probably be local to the module, rather than exported along with the functions. This would let you augment fromString down the road, without having to take into account, say, that the table could be modified behind your back.