Added check for valid constructor args to SubscriptionDefinition as well as a check on topic.length. Fixes #48

This commit is contained in:
ifandelse 2014-01-12 15:56:19 -05:00
parent 40897fac57
commit d25b1d0f48
3 changed files with 13 additions and 1 deletions

View file

@ -81,6 +81,12 @@
/* global postal */
/*jshint -W117 */
var SubscriptionDefinition = function ( channel, topic, callback ) {
if(arguments.length !== 3) {
throw new Error("You must provide a channel, topic and callback when creating a SubscriptionDefinition instance.");
}
if(topic.length === 0) {
throw new Error("Topics cannot be empty");
}
this.channel = channel;
this.topic = topic;
this.callback = callback;

2
lib/postal.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,12 @@
/* global postal */
/*jshint -W117 */
var SubscriptionDefinition = function ( channel, topic, callback ) {
if(arguments.length !== 3) {
throw new Error("You must provide a channel, topic and callback when creating a SubscriptionDefinition instance.");
}
if(topic.length === 0) {
throw new Error("Topics cannot be empty");
}
this.channel = channel;
this.topic = topic;
this.callback = callback;