Skip to content

Commit

Permalink
feat(Recipe): Add semver version validation
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Dec 15, 2017
1 parent 9e99675 commit 5826dc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/models/Recipe.js
Original file line number Diff line number Diff line change
@@ -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 = '';
Expand All @@ -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;
Expand Down

0 comments on commit 5826dc3

Please sign in to comment.