Skip to content

Commit 8e57cb6

Browse files
authored
Enhance color validation in Icon class
Added validation for hex color codes in Icon class.
1 parent 932a697 commit 8e57cb6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

folium/map.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,13 @@ def __init__(
353353
):
354354
super().__init__()
355355
self._name = "Icon"
356-
if color not in self.color_options:
356+
357+
# Check if the color is a valid hex code
358+
is_hex_color = color.startswith("#") and len(color) in (4, 7)
359+
360+
if color not in self.color_options and not is_hex_color:
357361
warnings.warn(
358-
f"color argument of Icon should be one of: {self.color_options}.",
362+
f"color argument of Icon should be one of: {self.color_options} or a valid hex color (e.g., '#FF0000').",
359363
stacklevel=2,
360364
)
361365
self.options = remove_empty(

0 commit comments

Comments
 (0)