in lib/configtools.ts [54:84]
export function isValidDeploymentRecord(record: DeploymentRecord|Deployment, regions: Array<string>): boolean {
// Check that attribute id exists and doesn't contain whitespaces
if (!record.id) {
throw new Error('Missing required attribute ID');
} else if (RegExp('\\s').test(record.id)) {
throw new Error('Attribute ID contains whitespace characters');
}
// Check that attribute type exists and is either of silo or pool
if (!record.type) {
throw new Error('Missing required attribute type');
} else if (record.type !== 'pool' && record.type !== 'silo') {
throw new Error('Attribute type is not either of pool or silo');
}
// Check that attribute account exists and has correct format
if (!record.account) {
throw new Error('Missing required attribute account');
} else if (!RegExp('^[0-9]{12}$').test(record.account)) {
throw new Error('Attribute account has invalid AWS account ID format');
}
// Check that attribute region exists and is one of correct regions
if (!record.region) {
throw new Error('Missing required attribute region');
} else if (!regions.includes(record.region)) {
throw new Error('Attribute region has invalid AWS region');
}
return true;
}