Skip to content
Permalink
Browse files
feat(Recipe): Add semver version validation
  • Loading branch information
adlk committed Dec 15, 2017
1 parent 9e99675 commit 5826dc3
Showing 1 changed file with 6 additions and 1 deletion.
@@ -1,10 +1,11 @@
import emailParser from 'address-rfc2822';
import semver from 'semver';

export default class Recipe {
id = '';
name = '';
description = '';
version = '1.0';
version = '';
path = '';

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

if (!semver.valid(data.version)) {
throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
}

this.id = data.id || this.id;
this.name = data.name || this.name;
this.rawAuthor = data.author || this.author;

0 comments on commit 5826dc3

Please sign in to comment.