Skip to content

Commit 068bd9c

Browse files
authored
Merge pull request #71 from serverless/validate-underscore-in-service-name
Add validation for underscores in service name
2 parents 3a40340 + 417b62b commit 068bd9c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

shared/validate.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ module.exports = {
2222

2323
// should not contain 'goog'
2424
if (name.match(/goog/)) {
25-
throw Error('Your service should not contain the string "goog"');
25+
throw new Error('Your service should not contain the string "goog"');
26+
}
27+
28+
if (name.match(/_+/)) {
29+
throw new Error('Your service name should not include underscores');
2630
}
2731

2832
return BbPromise.resolve();

shared/validate.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ describe('Validate', () => {
6868
expect(() => googleCommand.validateServiceName()).toThrow(Error);
6969
});
7070

71-
it('should not throw an error if the service name does not contain the string "goog"', () => {
71+
it('should throw an error if the service name contains underscores', () => {
72+
serverless.service.service = 'service_name';
73+
74+
expect(() => googleCommand.validateServiceName()).toThrow(Error);
75+
});
76+
77+
it('should not throw an error if the service name is valid', () => {
7278
serverless.service.service = 'service-name';
7379

7480
expect(() => googleCommand.validateServiceName()).not.toThrow(Error);

0 commit comments

Comments
 (0)