Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui / dist / forms / deps / isAlphaNumeric.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const exotic_1 = require("exotic");

const isNumberOrString = x => exotic_1.isNumber(x) || exotic_1.isString(x); // @note - this old credit card match does global match
// and has no begin/end so it will trigger falsy
// /[a-zA-Z0-9]/g


const matchLetters = /([a-zA-Z])/;
exports.matchLetters = matchLetters;
const matchNumbers = /([0-9])/;
exports.matchNumbers = matchNumbers;
const matchAlphaNumeric = /^[A-Za-z0-9]+$/;
const onlyAlphabets = /^[a-zA-Z]*$/;
const matchCity = /^[A-Za-z -]*$/;
const matchSpaces = /\s/g;
const matchAlphaNumericSpecialCharacters = /^[ A-Za-z0-9_@./#*!&+-]*$/;
const matchAlphaNumericMinusCharacter = /^[ A-Za-z0-9-]*$/;
const matchAlphaNumericPlusMinusCharacter = /^[ A-Za-z0-9+-]*$/;
/**
 * @alias isNumberOrStringOnly
 * @name isAlphaNumeric
 *
 * @description has only numbers & letters
 * @param {String | Number} value
 * @return {Boolean} is valid
 */

function isAlphaNumeric(value) {
  return exotic_1.isNumber(value) || isNumberOrString(value) && matchAlphaNumeric.test(value);
}

exports.isAlphaNumeric = isAlphaNumeric;
exports.isNumberOrStringOnly = isAlphaNumeric;

function isNonEmptyString(value) {
  return value !== '' && exotic_1.isString(value);
}

function isEmptyOrAlphaNumeric(value) {
  if (exotic_1.isEmpty(value)) {
    return true;
  } else {
    return isAlphaNumeric(value);
  }
}

exports.isEmptyOrAlphaNumeric = isEmptyOrAlphaNumeric;

function isAlphaNumericWithSpace(value) {
  const withoutSpaces = String(value).replace(matchSpaces, '');
  return value !== '' && isAlphaNumeric(withoutSpaces);
}

exports.isAlphaNumericWithSpace = isAlphaNumericWithSpace;

function isEmptyOrAlphaNumericWithSpace(value) {
  if (exotic_1.isEmpty(value)) {
    return true;
  } else {
    const withoutSpaces = String(value).replace(matchSpaces, '');
    return isAlphaNumeric(withoutSpaces);
  }
}

exports.isEmptyOrAlphaNumericWithSpace = isEmptyOrAlphaNumericWithSpace;

function isAlphaNumericWithPlusMinus(value) {
  return isNonEmptyString(value) && matchAlphaNumericPlusMinusCharacter.test(value);
}

exports.isAlphaNumericWithPlusMinus = isAlphaNumericWithPlusMinus;

function isEmptyOrAlphaNumericWithMinus(value) {
  if (exotic_1.isEmpty(value)) {
    return true;
  } else {
    return matchAlphaNumericMinusCharacter.test(value);
  }
}

exports.isEmptyOrAlphaNumericWithMinus = isEmptyOrAlphaNumericWithMinus;

function isNumeric(value) {
  return exotic_1.isNumber(value);
}

exports.isNumeric = isNumeric;

function isEmptyOrValidNumber(value) {
  if (exotic_1.isEmpty(value)) {
    return true;
  } else {
    return exotic_1.isNumber(value);
  }
}

exports.isEmptyOrValidNumber = isEmptyOrValidNumber;

function isAlphabet(value) {
  return isNonEmptyString(value) && onlyAlphabets.test(value);
}

exports.isAlphabet = isAlphabet;

function isValidCity(value) {
  return isNonEmptyString(value) && matchCity.test(value);
}

exports.isValidCity = isValidCity;

function isAlphaNumericSpecialCharacters(value) {
  return isNonEmptyString(value) && matchAlphaNumericSpecialCharacters.test(value);
}

exports.isAlphaNumericSpecialCharacters = isAlphaNumericSpecialCharacters;
exports.default = isAlphaNumeric; //# sourceMappingURL=isAlphaNumeric.js.map