UNPKG

@cto.ai/ops

Version:

💻 CTO.ai Ops - The CLI built for Teams 🚀

32 lines (31 loc) 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validChars = /^[a-zA-Z0-9-_]+$/; exports.validCharsTeamName = /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/; exports.validVersionChars = /^[\w][\w.-]{0,127}$/; exports.validOpsAddArg = /^@[a-z0-9]+([._-][a-z0-9]+)*\/[\w\d-_]+\:*([\w.-])*$/; exports.isValidOpName = (opName) => { return typeof opName === 'string' && exports.validChars.test(opName); }; exports.isValidTeamName = (teamName) => typeof teamName === 'string' && exports.validCharsTeamName.test(teamName); exports.isValidOpVersion = ({ version, }) => { return typeof version === 'string' && exports.validVersionChars.test(version); }; // RFCC 5322 official standard to validate emails exports.validateEmail = (email) => { return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email); }; exports.validatePasswordFormat = (input) => { if (input.length < 8) return `❗ This password is too short, please choose a password that is at least 8 characters long`; return true; }; exports.validateCpassword = (input, answers) => { if (input !== answers.password) { return `❗ Password doesn't match, please try again.`; } return true; }; exports.isValidOpFullName = (opFullName) => { return exports.validOpsAddArg.test(opFullName); };