From d3c56d3aa87fbf2d229301361636c920f0039305 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 24 Mar 2020 00:26:06 -0500 Subject: [PATCH] add validation to RGBColor --- color.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/color.go b/color.go index a86d07a..b22b4b8 100644 --- a/color.go +++ b/color.go @@ -78,6 +78,10 @@ var ( ) func NewRGBColor(r, g, b uint8) (*RGBColor, error) { + if (r < 0 || r > 255) && (g < 0 || r > 255) && (b < 0 || b > 255) { + return nil, errors.New("values must be between 0-255") + } + return &RGBColor{R: r, G: g, B: b}, nil }