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 / src / forms / deps / isAlphaNumeric.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
}); // import { isNumberOrString } from 'exotic'

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 = /\W+/gm

const matchSpaces = /\s/g;
const matchAlphaNumericSpecialCharacters = /^[ 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 isNumberOrString(value) && matchAlphaNumeric.test(value);
}

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

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

exports.isEmptyOrAlphaNumeric = isEmptyOrAlphaNumeric;

function isAddress(value) {
  const withoutSpaces = value.replace(matchSpaces, '');
  return isAlphaNumeric(withoutSpaces);
}

exports.isAddress = isAddress;

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 value && exotic_1.isString(value) && onlyAlphabets.test(value);
}

exports.isAlphabet = isAlphabet;

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

exports.isValidCity = isValidCity;

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

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