Fix bug in vc builder when a failing matchop blocks the vc

Change-Id: Iad46e92a7e3c5b57f016cff0f0cdfb67c8b9d0a1
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 24b24a7..4f7c7dc 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -156,13 +156,13 @@
 
       // No valid string
       doc = stringFactory.create({
-	value : { "foo" : "bar" }
+	      value : { "foo" : "bar" }
       });
       expect(doc).toBeUndefined();
 
       // Change match type
       doc = stringFactory.create({
-	"match" : "match:ne"
+	      "match" : "match:ne"
       });
 
       expect(doc.matchop()).toEqual('ne');
@@ -172,7 +172,7 @@
 
       // Invalid match type
       doc = stringFactory.create({
-	"match" : { "foo" : "bar" }
+	      "match" : { "foo" : "bar" }
       });
       expect(doc).toBeUndefined();
     });
@@ -186,19 +186,21 @@
 
       // change matcher
       doc = regexFactory.create({
-	match : "match:ne"
+	      match : "match:ne"
       });
       expect(doc.matchop()).toEqual('ne');
+      expect(doc.rewrites()).toBeUndefined();
 
       // Invalid matcher
       doc = regexFactory.create({
-	match : "match:chook"
+	      match : "match:chook"
       });
-      expect(doc).toBeUndefined();
+      expect(doc.matchop()).toEqual('eq');
+      expect(doc.rewrites()).toBeDefined();
 
       // Invalid regex
       doc = regexFactory.create({
-	value : "[^b"
+	      value : "[^b"
       });
       expect(doc).toBeUndefined();
     });
@@ -215,7 +217,7 @@
 
       // Short date 1
       doc = dateFactory.create({
-	"value" : "2014-11"
+	      "value" : "2014-11"
       });
 
       expect(doc.matchop()).toEqual('eq');
@@ -225,7 +227,7 @@
 
       // Short date 2
       doc = dateFactory.create({
-	"value" : "2014"
+	      "value" : "2014"
       });
 
       expect(doc.matchop()).toEqual('eq');
@@ -235,15 +237,17 @@
 
       // Invalid date!
       doc = dateFactory.create({
-	"value" : "2014-11-050"
+	      "value" : "2014-11-050"
       });
       expect(doc).toBeUndefined();
 
       // Invalid matcher!
       doc = dateFactory.create({
-	"match" : "match:ne",
+	      "match" : "match:ne",
       });
-      expect(doc).toBeUndefined();
+      expect(doc).toBeDefined();
+      expect(doc.rewrites()).toBeDefined();
+      expect(doc.matchop()).toEqual('eq');
     });
 
     it('should be serializale to JSON', function () {
@@ -285,11 +289,11 @@
 
       doc = dateFactory.create();
       expect(doc.toJson()).toEqual(jasmine.objectContaining({
-	"@type" : "koral:doc",
-	"type" : "type:date",
-	"value" : "2014-11-05",
-	"match" : "match:eq",
-	"key" : 'pubDate'
+	      "@type" : "koral:doc",
+	      "type" : "type:date",
+	      "value" : "2014-11-05",
+	      "match" : "match:eq",
+	      "key" : 'pubDate'
       }));
 
       doc = dateFactory.create({