forked from garycourt/JSV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug with extended schemas that contain a "pattern" attribute. (…
…Identified by DrDyne)
- Loading branch information
Showing
9 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* @fileOverview Implementation of the first revision of the JSON Schema specification draft. | ||
* @author <a href="mailto:[email protected]">Gary Court</a> | ||
* @version 1.6 | ||
* @version 1.7 | ||
* @see http://github.com/garycourt/JSV | ||
*/ | ||
|
||
|
@@ -451,21 +451,15 @@ | |
|
||
"parser" : function (instance, self) { | ||
if (instance.getType() === "string") { | ||
try { | ||
return new RegExp(instance.getValue()); | ||
} catch (e) { | ||
return e; | ||
} | ||
return instance.getValue(); | ||
} | ||
}, | ||
|
||
"validator" : function (instance, schema, self, report, parent, parentSchema, name) { | ||
var pattern; | ||
try { | ||
pattern = schema.getAttribute("pattern"); | ||
if (pattern instanceof Error) { | ||
report.addError(instance, schema, "pattern", "Invalid pattern", pattern); | ||
} else if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
pattern = new RegExp(schema.getAttribute("pattern")); | ||
if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
report.addError(instance, schema, "pattern", "String does not match pattern", pattern.toString()); | ||
} | ||
} catch (e) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* @fileOverview Implementation of the second revision of the JSON Schema specification draft. | ||
* @author <a href="mailto:[email protected]">Gary Court</a> | ||
* @version 1.6 | ||
* @version 1.7 | ||
* @see http://github.com/garycourt/JSV | ||
*/ | ||
|
||
|
@@ -475,21 +475,15 @@ | |
|
||
"parser" : function (instance, self) { | ||
if (instance.getType() === "string") { | ||
try { | ||
return new RegExp(instance.getValue()); | ||
} catch (e) { | ||
return e; | ||
} | ||
return instance.getValue(); | ||
} | ||
}, | ||
|
||
"validator" : function (instance, schema, self, report, parent, parentSchema, name) { | ||
var pattern; | ||
try { | ||
pattern = schema.getAttribute("pattern"); | ||
if (pattern instanceof Error) { | ||
report.addError(instance, schema, "pattern", "Invalid pattern", pattern); | ||
} else if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
pattern = new RegExp(schema.getAttribute("pattern")); | ||
if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
report.addError(instance, schema, "pattern", "String does not match pattern", pattern.toString()); | ||
} | ||
} catch (e) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* @fileOverview Implementation of the third revision of the JSON Schema specification draft. | ||
* @author <a href="mailto:[email protected]">Gary Court</a> | ||
* @version 1.4 | ||
* @version 1.5 | ||
* @see http://github.com/garycourt/JSV | ||
*/ | ||
|
||
|
@@ -477,21 +477,15 @@ | |
|
||
"parser" : function (instance, self) { | ||
if (instance.getType() === "string") { | ||
try { | ||
return new RegExp(instance.getValue()); | ||
} catch (e) { | ||
return e; | ||
} | ||
return instance.getValue(); | ||
} | ||
}, | ||
|
||
"validator" : function (instance, schema, self, report, parent, parentSchema, name) { | ||
var pattern; | ||
try { | ||
pattern = schema.getAttribute("pattern"); | ||
if (pattern instanceof Error) { | ||
report.addError(schema, self, "pattern", "Invalid pattern", schema.getValueOfProperty("pattern")); | ||
} else if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
pattern = new RegExp(schema.getAttribute("pattern")); | ||
if (instance.getType() === "string" && pattern && !pattern.test(instance.getValue())) { | ||
report.addError(instance, schema, "pattern", "String does not match pattern", pattern.toString()); | ||
} | ||
} catch (e) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* @fileOverview A JavaScript implementation of a extendable, fully compliant JSON Schema validator. | ||
* @author <a href="mailto:[email protected]">Gary Court</a> | ||
* @version 4.0 | ||
* @version 4.0.1 | ||
* @see http://github.com/garycourt/JSV | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name" : "JSV", | ||
"version" : "4.0.0", | ||
"version" : "4.0.1", | ||
"description" : "A JavaScript implementation of a extendable, fully compliant JSON Schema validator.", | ||
"homepage" : "http://github.com/garycourt/JSV", | ||
"author" : "Gary Court <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters