Skip to content

Commit eb787ef

Browse files
acconradprofnandaa
authored andcommitted
feat(isHexColor): support css colors level 4 spec (#1233)
1 parent 13d7045 commit eb787ef

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/lib/isHexColor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assertString from './util/assertString';
22

3-
const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;
3+
const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
44

55
export default function isHexColor(str) {
66
assertString(str);

test/validators.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,14 +2588,16 @@ describe('Validators', () => {
25882588
test({
25892589
validator: 'isHexColor',
25902590
valid: [
2591+
'#ff0000ff',
25912592
'#ff0034',
25922593
'#CCCCCC',
2594+
'0f38',
25932595
'fff',
25942596
'#f00',
25952597
],
25962598
invalid: [
25972599
'#ff',
2598-
'fff0',
2600+
'fff0a',
25992601
'#ff12FG',
26002602
],
26012603
});

0 commit comments

Comments
 (0)