Skip to content
Permalink
Browse files

feat(Recipe): Add semver version validation

  • Loading branch information
adlk committed Dec 15, 2017
1 parent 9e99675 commit 5826dc36797b3d1d96ec986437003e5fc2626e91
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/models/Recipe.js
@@ -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.
You can’t perform that action at this time.