Skip to content

Commit

Permalink
Merge pull request #343 from canne/master
Browse files Browse the repository at this point in the history
from isHexNumber to isHexColor
  • Loading branch information
robertsLando committed Jan 15, 2020
2 parents 8e22994 + 676a595 commit 2b34083
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,8 @@
function updateProp(obj, option, val) {
switch (option) {
case 'valueFontColor':
if (!isHexNumber(val)) {
console.log('* justgage: the updated valueFontColor value is not a valid hex value');
if (!isHexColor(val)) {
console.log('* justgage: the updated valueFontColor value is not a valid hex color');
break;
}

Expand All @@ -1042,8 +1042,8 @@
break;

case 'labelFontColor':
if (!isHexNumber(val)) {
console.log('* justgage: the updated labelFontColor value is not a valid hex value');
if (!isHexColor(val)) {
console.log('* justgage: the updated labelFontColor value is not a valid hex color');
break;
}

Expand Down Expand Up @@ -1268,13 +1268,13 @@
}

/**
* Validate if hex value
* Validate if html hex color presentation
*
* @param val
* @returns {*|boolean}
*/
function isHexNumber(val) {
var regExp = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
function isHexColor(val) {
var regExp = /^#([0-9A-Fa-f]{3}){1,2}$/;
return (typeof val === 'string' && regExp.test(val));
}

Expand Down

0 comments on commit 2b34083

Please sign in to comment.