Skip to content

Commit 5826dc3

Browse files
committed
feat(Recipe): Add semver version validation
1 parent 9e99675 commit 5826dc3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/models/Recipe.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import emailParser from 'address-rfc2822';
2+
import semver from 'semver';
23

34
export default class Recipe {
45
id = '';
56
name = '';
67
description = '';
7-
version = '1.0';
8+
version = '';
89
path = '';
910

1011
serviceURL = '';
@@ -31,6 +32,10 @@ export default class Recipe {
3132
throw Error(`Recipe '${data.name}' requires Id`);
3233
}
3334

35+
if (!semver.valid(data.version)) {
36+
throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
37+
}
38+
3439
this.id = data.id || this.id;
3540
this.name = data.name || this.name;
3641
this.rawAuthor = data.author || this.author;

0 commit comments

Comments
 (0)