converts a hex number to its css-friendly counterpart, with optional alpha transparency field returns undefined if the input is cannot be parsed to a valid number or if the number is out of range
556739
function(hexNum, alpha) {
            if(typeof hexNum !== "number") {
                hexNum = parseInt(hexNum, 16);
            }
            if(isNaN(hexNum) || hexNum < 0x000000 || hexNum > 0xffffff) {
                return undefined;
            }
            var r = (hexNum & 0xff0000) >> 16,
                g = (hexNum & 0x00ff00) >> 8,
                b = hexNum & 0x0000ff;

            return ((alpha === undefined) ? ("rgb(" + r + "," + g + "," + b + ")") : ("rgba(" + r + "," + g + "," + b + "," + alpha + ")"));
        }
254409
private static final String toBrowserHexValue(final int number)
    {
        final String chex = Integer.toHexString(fixRGB(number) & 0xFF).toUpperCase();

        if (chex.length() < 2)
        {
            return "0" + chex;
        }
        return chex;
    }
1056966
function filter_number(value) {
    var m = NUMBER_RE.exec(value);
    if(m == null) throw OptError('Expected a number representative');
    if(m[1]) {
        // The number is in HEX format. Convert into a number, then return it
        return parseInt(m[1], 16);
    } else {
        // The number is in regular- or decimal form. Just run in through
        // the float caster.
        return parseFloat(m[2] || m[3]);
    }
}
1013355
function setHex(color, hex) {
    hex = hex.replace(/^#/, "");
    var num = parseInt(hex, 16);

    color[0] = (num >> 16 & 255) / 255;
    color[1] = (num >> 8 & 255) / 255;
    color[2] = (num & 255) / 255;
    color[3] = 1

    return color;
}
476857
function( input ) {

    var len = input.length
    var chr, out = ''

    function hex( number ) {
      return number.toString( 16 ).toUpperCase()
    }

    for( var i = 0; i < len; i++ ) {
      chr = input.charCodeAt( i )
      if( chr >= 0x41 && chr <= 0x5A ) {
        out = out + input[i]
      } else if( chr >= 0x61 && chr <= 0x7A ) {
        out = out + input[i]
      } else if( chr >= 0x30 && chr <= 0x39 ) {
        out = out + input[i]
      } else if( input[i].match( /[-_.!~*'()]/ ) ) {
        out = out + input[i]
      } else if( chr <= 0x007F ) {
        out = out + '%' + hex( chr )
      } else if( chr <= 0x07FF ) {
        out = out + '%' + hex( 0xC0 | (chr >>   6) )
        out = out + '%' + hex( 0x80 | (chr & 0x3F) )
      } else {
        out = out + '%' + hex( 0xE0 | (chr >> 12) )
        out = out + '%' + hex( 0x80 | ((chr >> 6) & 0x3F) )
        out = out + '%' + hex( 0x80 | (chr & 0x3F) )
      }
    }

    return out

  }
129528
function(color) {
				if (!color || color === "") {
					return _colorLookup.black;
				} else if (_colorLookup[color]) {
					return _colorLookup[color];
				} else if (typeof(color) === "number") {
					return [color >> 16, (color >> 8) & 255, color & 255];
				} else if (color.charAt(0) === "#") {
					if (color.length === 4) { //for shorthand like #9F0
						color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
					}
					color = parseInt(color.substr(1), 16);
					return [color >> 16, (color >> 8) & 255, color & 255];
				} else {
					return color.match(_numExp) || _colorLookup.transparent;
				}
			}
762083
function rgb(hexStr) {
  const hex = hexStr.replace(/^#/, '');
  const fullHex = hex.length === 3
    ? `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`
    : hex;

  const num = parseInt(fullHex, 16);
  // eslint-disable-next-line no-bitwise, no-mixed-operators
  return [num >> 16, num >> 8 & 255, num & 255].join(', ');
}
633459
function(num){
    if(_.isUndefined(num) || num == 0)
        num = '00';

    if(_.isString(num) || _.isNumber(num))
        num = new BigNumber(String(num));

    if(isBigNumber(num))
        num = num.toString(16);

    return formatHex(num);
}
823100
function () {

// Parse a number value.

            var number,
                string = '';

            if (ch === '-') {
                string = '-';
                next('-');
            }
            while (ch >= '0' && ch <= '9') {
                string += ch;
                next();
            }
            if (ch === '.') {
                string += '.';
                while (next() && ch >= '0' && ch <= '9') {
                    string += ch;
                }
            }
            if (ch === 'e' || ch === 'E') {
                string += ch;
                next();
                if (ch === '-' || ch === '+') {
                    string += ch;
                    next();
                }
                while (ch >= '0' && ch <= '9') {
                    string += ch;
                    next();
                }
            }
            number = +string;
            if (isNaN(number)) {
                error("Bad number");
            } else {
                return number;
            }
        }
817263
def StrictlyAlphanumeric(msg=None):
    '''
    
    '''
    def fn(value):
        if not (
            isinstance(value, basestring) and
            value.isalnum() and not
            value.isdigit() and not
            value.isalpha()
        ):
            raise Invalid(msg or (
                'Invalid input <{0}>; expected an integer'.format(value))
            )
        else:
            return value
    return fn
701809
def normalize_hex(hex_value):
    
    match = HEX_COLOR_RE.match(hex_value)
    if match is None:
        raise ValueError(
            u"'{}' is not a valid hexadecimal color value.".format(hex_value)
        )
    hex_digits = match.group(1)
    if len(hex_digits) == 3:
        hex_digits = u''.join(2 * s for s in hex_digits)
    return u'#{}'.format(hex_digits.lower())
1355864
function(hex, opacity) {
  let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return result ? "rgba(" + parseInt(result[1], 16) + ", " + parseInt(result[2], 16) + ", " + parseInt(result[3], 16) + ", " + opacity + ")" : hex;
}
1054988
function getAlphaHex(alpha) {
    var num = Math.round(alpha * 255);
    var hex = num.toString(16);

    return hex.length === 1 ? '0' + hex : hex;
}
82280
function stringify (values, type) {
	// Accept object from `color-parse`
	if (!Array.isArray(values) && values.values) {
		var color = values
		if (color.alpha === 1 || color.alpha === undefined) {
			return stringify(color.values, type || color.space)
		} else {
			var values = color.values.slice()
			values.push(color.alpha)
			return stringify(values, type || color.space)
		}
	}

	if (type === 'hex') {
		var res = values.slice(0,3).map(function (value) {
			return (value < 16 ? '0' : '') + value.toString(16);
		}).join('');

		if (res[0] === res[1] && res[2] === res[3] && res[4] === res[5]) res = res[0] + res[2] + res[4];

		return '#' + res;
	}

	if (type === 'keyword') {
		return nameValues[values];
	}

	if (type === 'adobe1') {
		return 'R:' + values[0] + ', G:' + values[1] + ', B:' + values[2];
	}

	if (type === 'adobe2') {
		return '(R' + values[0] + ' / G' + values[1] + ' / B' + values[2] + ')';
	}

	var isPercent, isAlphaSpace;

	//convert rgb to percents
	if (type === 'percent') {
		type = 'rgb';
		values = values.map(function (value, i) {
			if (i === 3) return value;
			return Math.round(value * 100 / 255);
		});

		isPercent = true;
		isAlphaSpace = true;
	}

	type = type || 'rgb';

	//catch hwb/hsl/hsv
	isPercent = isPercent ? isPercent : type[0] === 'h';

	//detect whether alpha-perfix is needed
	isAlphaSpace = isAlphaSpace || /rgb|hs[lv]/i.test(type);

	//normalize space name
	if (isAlphaSpace && type[type.length - 1] === 'a') {
		type = type.slice(0,-1);
	}

	//normalize alpha
	var alpha = 1;
	if (values.length > type.length) {
		alpha = values.pop();
	}

	//decide the space name
	var alphaPf = isAlphaSpace && alpha < 1 ? 'a' : '';

	//<hue> case requires percents
	var res = type + alphaPf;

	res += '(' + values.map(function (value, i) {
		if (isPercent && !(type[i] === 'h')) {
			return value + '%';
		}
		else {
			return value;
		}
	}).join(', ');

	res += ( alpha < 1 ? ', ' + alpha : '' ) + ')';

	return res;
}
631945
function normalizeValue(value) {
		if (value.charAt(0) == '-' && !/^\-[\.\d]/.test(value)) {
			value = value.replace(/^\-+/, '');
		}
		
		var ch = value.charAt(0);
		if (ch == '#') {
			return normalizeHexColor(value);
		}

		if (ch == '$') {
			return utils.escapeText(value);
		}

		return getKeyword(value);
	}
1307228
function(value) {
        if(value.length != 6)
            throw new Error("Hexa color: bad length");
        value = value.toLowerCase();
        for(i in value) {
            var c = value.charCodeAt(i);
            console.log(c);
            if( !((c>=49 && c<=57) || (c>=97 && c<=102)) )
                throw new Error("Hexa color: out of range for " + value + " at position " + i);
        }
    }
141262
function number(event) {
    var element = event.element
      , value = element.value
      , key = this.digit(event)
      , valid;

    //
    // Input must be numerical.
    //
    if (!key.allowed && event.type !== 'blur') return;

    //
    // Always format if the event is of type blur. This will ensure the input
    // box does not stay red on blur if formatted value is valid.
    //
    if (event.type === 'blur') this.number.set('value', this.lib.format(value));

    //
    // Check if the number is valid.
    //
    if (value.replace(/\D/g, '').length >= 16 || key.removal) {
      valid = this.lib.validate(value);

      //
      // Show card type or hide if invalid.
      //
      this.card[valid ? 'removeClass' : 'addClass']('gone');
      this.card.find('strong').set('innerHTML', this.lib.cardscheme(value));

      if (this.validate) {
        //
        // Check against testnumbers in production mode. Valid should be checked
        // as well, otherwise an incomplete credit card number would be valid.
        //
        if (this.production) {
          valid = valid && !~this.lib.testnumbers.indexOf(+value.replace(/\D/g, ''));
        }

        //
        // Update the styling of the input.
        //
        this.number.set('className', valid ? 'valid' : 'invalid');
      }
    }

    //
    // Add spaces for each block of 4 characters.
    //
    this.number.set('value', this.lib.format(value));
  }