Skip to content

Commit 6419d29

Browse files
committed
Initial commit.
1 parent 246ff8f commit 6419d29

22 files changed

+2611
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
coverage

.jshintrc

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"undef": true,
3+
"unused": true,
4+
"browser": true,
5+
"globals": {
6+
"console":false,
7+
"jQuery": false,
8+
"$":false,
9+
"assertEquals": false,
10+
"jstestdriver": false,
11+
"assertTrue": false,
12+
"assertFalse": false,
13+
"describe": false,
14+
"it":false,
15+
"expect": false,
16+
"sinon":false,
17+
"beforeEach": false,
18+
"afterEach": false,
19+
"angular": false,
20+
"module": false,
21+
"inject": false,
22+
"chai": false,
23+
"should": false,
24+
"Jed": false,
25+
"tws": false
26+
}
27+
}

bower.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "schema",
3+
"version": "0.0.0",
4+
"authors": [
5+
"David Jensen <[email protected]>"
6+
],
7+
"moduleType": [
8+
"globals"
9+
],
10+
"license": "MIT",
11+
"private": true,
12+
"ignore": [
13+
"**/.*",
14+
"node_modules",
15+
"bower_components",
16+
"test",
17+
"tests"
18+
],
19+
"dependencies": {
20+
"tv4": "~1.0.15"
21+
}
22+
}

bower_components/tv4/.bower.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "tv4",
3+
"version": "1.0.15",
4+
"description": "A public domain JSON Schema validator for JavaScript",
5+
"keywords": [
6+
"json-schema",
7+
"schema",
8+
"validator",
9+
"tv4"
10+
],
11+
"license:": [
12+
{
13+
"type": "Public Domain",
14+
"url": "http://geraintluff.github.io/tv4/LICENSE.txt"
15+
},
16+
{
17+
"type": "MIT",
18+
"url": "http://jsonary.com/LICENSE.txt"
19+
}
20+
],
21+
"main": "tv4.js",
22+
"ignore": [
23+
"*.html",
24+
"*.txt",
25+
"*.min.js",
26+
"*.js.map",
27+
"*.md",
28+
"Gruntfile.js",
29+
"package.json",
30+
"component.json",
31+
"bower.json",
32+
"node_modules",
33+
"test",
34+
"try",
35+
"lang",
36+
"build",
37+
"dist",
38+
"doc",
39+
"source",
40+
".*"
41+
],
42+
"homepage": "https://github.com/geraintluff/tv4",
43+
"_release": "1.0.15",
44+
"_resolution": {
45+
"type": "version",
46+
"tag": "v1.0.15",
47+
"commit": "273d12faaef298eb76399b6c0a380a871d07f20b"
48+
},
49+
"_source": "git://github.com/geraintluff/tv4.git",
50+
"_target": "~1.0.15",
51+
"_originalSource": "tv4",
52+
"_direct": true
53+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Provides support for asynchronous validation (fetching schemas) using jQuery
2+
// Callback is optional third argument to tv4.validate() - if not present, synchronous operation
3+
// callback(result, error);
4+
if (typeof (tv4.asyncValidate) === 'undefined') {
5+
tv4.syncValidate = tv4.validate;
6+
tv4.validate = function (data, schema, callback, checkRecursive, banUnknownProperties) {
7+
if (typeof (callback) === 'undefined') {
8+
return this.syncValidate(data, schema, checkRecursive, banUnknownProperties);
9+
} else {
10+
return this.asyncValidate(data, schema, callback, checkRecursive, banUnknownProperties);
11+
}
12+
};
13+
tv4.asyncValidate = function (data, schema, callback, checkRecursive, banUnknownProperties) {
14+
var $ = jQuery;
15+
var result = tv4.validate(data, schema, checkRecursive, banUnknownProperties);
16+
if (!tv4.missing.length) {
17+
callback(result, tv4.error);
18+
} else {
19+
// Make a request for each missing schema
20+
var missingSchemas = $.map(tv4.missing, function (schemaUri) {
21+
return $.getJSON(schemaUri).success(function (fetchedSchema) {
22+
tv4.addSchema(schemaUri, fetchedSchema);
23+
}).error(function () {
24+
// If there's an error, just use an empty schema
25+
tv4.addSchema(schemaUri, {});
26+
});
27+
});
28+
// When all requests done, try again
29+
$.when.apply($, missingSchemas).done(function () {
30+
var result = tv4.asyncValidate(data, schema, callback, checkRecursive, banUnknownProperties);
31+
});
32+
}
33+
};
34+
}

0 commit comments

Comments
 (0)