 Channel = require('../model/channels').Channel
 Q = require 'q'
 logger = require 'winston'
+
+isPathValid = (channel) ->
+	# There cannot be both path and pathTranform. pathTransform must be valid
+	not (channel.path and channel.pathTransform) and (not channel.pathTranform or /s\/.*\/.*/.test channel.pathTransform)
 
 ###
 # Retrieves the list of active channels

		delete channelData._id;
	}

	try {
		yield Channel.findOneAndUpdate({ name: channel_name }, channelData).exec();



	try {
		var channel = new Channel(channelData);

		if (!isPathValid(channel)) {
			this.body = 'Channel cannot have both path and pathTransform. pathTransform must be of the form s/from/to[/g]';
			this.status = 400;
			return;
		}

		var result = yield Q.ninvoke(channel, 'save');

		// All ok! So set the result
