export class StringUtils { static isValidBoolean ( value ) { return ( value === 'true' || value === 'false' || value === true || value === false ) ; } static isValidInteger ( value ) { const parsedInt = parseInt ( value , 10 ) ; return ! isNaN ( parsedInt ) ; } static parseBoolean ( value , errorMessage ? ) { if ( ! StringUtils . isValidBoolean ( value ) ) { const message = errorMessage || `${ value } is not a valid boolean!` ; throw new Error ( message ) ; } return StringUtils . convertStringToBoolean ( value ) ; } static parseInt ( value , errorMessage ? ) { if ( ! StringUtils . isValidInteger ( value ) ) { const message = errorMessage || `${ value } is not a valid int!` ; throw new Error ( message ) ; } return parseInt ( value , 10 ) ; } private static convertStringToBoolean ( value ) { return value === 'true' ; } }