Skip to content

Commit 70e7919

Browse files
authored
Create validateHexColor.js
1 parent 44deb4e commit 70e7919

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* HHexadecimal color pattern. The following formats are allowed:
3+
* #ABC | #AB1 | #123
4+
* #ABCDEF | #ABC123 | #123456
5+
*/
6+
const hexColorRegex = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/g;
7+
8+
const colorCode = "#ABC123";
9+
10+
if (hexColorRegex.test(colorCode)) {
11+
gs.info("Valid hexadecimal color");
12+
}
13+
else {
14+
gs.info("Invalid hexadecimal color");
15+
}

0 commit comments

Comments
 (0)