
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A utility library for generating random numbers, strings, and validating phone numbers across various formats.
A utility library for generating random numbers, strings, and validating phone numbers.
Randcraft provides developers with essential functions to handle randomness and phone number validation
making it easier to integrate these features into applications.
The phone number validation function allows you to verify if a given phone number is valid according
to specific country formats. Supported countries include:
To use the library, first install it via npm:
npm install randcraft
Importing Functions
Using CommonJS (Node.js)
const { generateRandomNumber, generateRandomString, validatePhoneNumber } = require('randcraft');
Using ES6 Modules
If you're using a module bundler or an environment that supports ES6 modules, you can import the library as follows:
import { generateRandomNumber, generateRandomString, validatePhoneNumber } from 'randcraft';
Public Methods
validatePhoneNumber(phoneNumber, country = 'GE')
Validates a phone number based on common patterns for different countries. The country parameter can be
specified to validate against a specific country's format (default is Georgia).
The function also allows validation without the country code.
Parameters:
phoneNumber (string): The phone number to validate.
country (string, optional): The country code (default is 'GE' for Georgia).
Returns: true if the phone number is valid; otherwise, false.
console.log(validatePhoneNumber("+995 599 123 456")); // true (valid Georgian number)
console.log(validatePhoneNumber("599 123 456")); // true (valid Georgian number without country code)
console.log(validatePhoneNumber("+1 123 456 7890", 'US')); // true (valid US number)
Parameters:
min (number): The minimum value (inclusive).
max (number): The maximum value (inclusive).
Returns: A random integer between min and max.
Example:
const randomNumber = generateRandomNumber(1, 100);
console.log(randomNumber); // Example output: 42
generateRandomString(length)
Generates a random string of the specified length using alphanumeric characters.
Parameters:
length (number): The length of the generated string.
Returns: A random alphanumeric string.
Example:
const randomString = generateRandomString(10);
console.log(randomString); // Example output: 'a1b2c3d4e5'
License
This project is licensed under the MIT License.
Author
Arsen Akhalaia
FAQs
A utility library for generating random numbers, strings, and validating phone numbers across various formats.
We found that randcraft demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.