file copyright author Vivek M. Chawla <@VivekMChawla>
 *  summary description version license import { SfdxFalconDebug } from '../sfdx-falcon-debug' ; import { SfdxFalconError } from '../sfdx-falcon-error' ; import { isGitUriValid } from './git-validator' ; const dbgNs = 'VALIDATOR:core:' ; const standardAlias = /^[a-zA-Z0-9_-]+$/ ; const standardName = /^[\w\-\_\'\s]+$/ ; function param { string } gitRemoteUri param { RegExp } acceptedProtocols returns { boolean } description public export function validateGitRemoteUri ( gitRemoteUri , acceptedProtocols ? ) { SfdxFalconDebug . obj ( `${ dbgNs }validateGitRemoteUri:arguments:` , arguments , `validateGitRemoteUri:arguments: ` ) ; return isGitUriValid ( gitRemoteUri , acceptedProtocols ) ; } function param { string } pathString returns { boolean } description public export function validateLocalPath ( pathString ) { SfdxFalconDebug . obj ( `${ dbgNs }validateLocalPath:arguments:` , arguments , `validateLocalPath:arguments: ` ) ; if ( typeof pathString !== 'string' ) { throw new SfdxFalconError ( `Expected pathString to be type string but got '${ typeof pathString }' instead. ` , `TypeError` , `${ dbgNs }validateLocalPath` ) ; } const localPathValidationRegex = new RegExp ( '(^[~]|\\s|\\"|\\\'|\\`|\\&|\\;|\\||\\*)' ) ; return ( ! localPathValidationRegex . test ( pathString ) ) ; } function param { string } alias param { number } maxLength returns { boolean } description public export function validateStandardAlias ( alias , maxLength ? ) { SfdxFalconDebug . obj ( `${ dbgNs }validateStandardAlias:arguments:` , arguments , `validateStandardAlias:arguments: ` ) ; if ( typeof alias !== 'string' ) { throw new SfdxFalconError ( `Expected alias to be type string but got '${ typeof alias }' instead. ` , `TypeError` , `${ dbgNs }validateStandardAlias` ) ; } if ( standardAlias . test ( alias ) ) { if ( typeof maxLength === 'number' ) { if ( alias . length <= maxLength ) { return true ; } } else { return true ; } } return false ; } function param { string } name param { number } maxLength returns { boolean } description public export function validateStandardName ( name , maxLength ? ) { SfdxFalconDebug . obj ( `${ dbgNs }validateStandardName:arguments:` , arguments , `arguments: ` ) ; if ( typeof name !== 'string' ) { throw new SfdxFalconError ( `Expected name to be type string but got '${ typeof name }' instead. ` , `TypeError` , `${ dbgNs }validateStandardName` ) ; } if ( standardName . test ( name ) ) { if ( typeof maxLength === 'number' ) { if ( name . length <= maxLength ) { return true ; } } else { return true ; } } return false ; }