diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-12-15 14:42:45 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-12-15 14:42:45 +0100 |
commit | 5826dc36797b3d1d96ec986437003e5fc2626e91 (patch) | |
tree | 2364ae9e32550f2857d1b2fbf30fd26a5851e8ee /src | |
parent | Add missing translation strings (diff) | |
download | ferdium-app-5826dc36797b3d1d96ec986437003e5fc2626e91.tar.gz ferdium-app-5826dc36797b3d1d96ec986437003e5fc2626e91.tar.zst ferdium-app-5826dc36797b3d1d96ec986437003e5fc2626e91.zip |
feat(Recipe): Add semver version validation
Diffstat (limited to 'src')
-rw-r--r-- | src/models/Recipe.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js index 036d6d216..1fc23ac89 100644 --- a/src/models/Recipe.js +++ b/src/models/Recipe.js | |||
@@ -1,10 +1,11 @@ | |||
1 | import emailParser from 'address-rfc2822'; | 1 | import emailParser from 'address-rfc2822'; |
2 | import semver from 'semver'; | ||
2 | 3 | ||
3 | export default class Recipe { | 4 | export default class Recipe { |
4 | id = ''; | 5 | id = ''; |
5 | name = ''; | 6 | name = ''; |
6 | description = ''; | 7 | description = ''; |
7 | version = '1.0'; | 8 | version = ''; |
8 | path = ''; | 9 | path = ''; |
9 | 10 | ||
10 | serviceURL = ''; | 11 | serviceURL = ''; |
@@ -31,6 +32,10 @@ export default class Recipe { | |||
31 | throw Error(`Recipe '${data.name}' requires Id`); | 32 | throw Error(`Recipe '${data.name}' requires Id`); |
32 | } | 33 | } |
33 | 34 | ||
35 | if (!semver.valid(data.version)) { | ||
36 | throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); | ||
37 | } | ||
38 | |||
34 | this.id = data.id || this.id; | 39 | this.id = data.id || this.id; |
35 | this.name = data.name || this.name; | 40 | this.name = data.name || this.name; |
36 | this.rawAuthor = data.author || this.author; | 41 | this.rawAuthor = data.author || this.author; |