export const CARD_ID_REGEX = /^(?:[0-9]{4} ?){5}$/i; /** * Generates a random Aime card id. */ export function generateAimeCardId(): string { let cardId = ''; while (true) { // don't start with a 3 const firstDigit = Math.floor(Math.random() * 10); if (firstDigit !== 3) { cardId = firstDigit.toString(); break; } } for (let i = 0; i < 19; i++) { cardId += Math.floor(Math.random() * 10).toString(); } return cardId; } /** * Validates the provided card id by known parameters * @param id The card id to validate */ export function validateAimeCardId(id: string): boolean { return id[0] !== '3' && CARD_ID_REGEX.test(id); }