aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-15 14:44:17 +0100
committerLibravatar GitHub <noreply@github.com>2017-12-15 14:44:17 +0100
commit10d33532382f30b73a13adcc4724c522633812fd (patch)
treedc49a770ad7cbcdbd6ad45f78987e609628fb853 /src
parentMerge pull request #474 from meetfranz/feature/service-improvements (diff)
parentfeat(Recipe): Add semver version validation (diff)
downloadferdium-app-10d33532382f30b73a13adcc4724c522633812fd.tar.gz
ferdium-app-10d33532382f30b73a13adcc4724c522633812fd.tar.zst
ferdium-app-10d33532382f30b73a13adcc4724c522633812fd.zip
Merge pull request #475 from meetfranz/feature/service-improvements
feat(Recipe): Add semver version validation
Diffstat (limited to 'src')
-rw-r--r--src/models/Recipe.js7
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 @@
1import emailParser from 'address-rfc2822'; 1import emailParser from 'address-rfc2822';
2import semver from 'semver';
2 3
3export default class Recipe { 4export 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;