Skip to content

Commit 9cd043e

Browse files
committed
Merge branch 'master' into gh-661
2 parents 1e80548 + f78e064 commit 9cd043e

26 files changed

+18764
-199
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: node_js
22
node_js:
3-
- 0.8
43
- 0.10
54
services:
65
- mongodb

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@ copyunstable:
7070

7171
browser:
7272
./node_modules/browserify/bin/cmd.js -o ./bin/mongoose.js lib/browser.js
73+
74+
browser_debug:
75+
./node_modules/browserify/bin/cmd.js -o ./bin/mongoose.debug.js lib/browser.js -d
76+
77+
test_browser:
78+
./node_modules/karma/bin/karma start karma.local.conf.js

bin/browser_debug.html

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,61 @@
22
<html>
33
<head>
44
<title>Mongoose browser debug</title>
5-
<script src="mongoose.js"></script>
5+
<script src="mongoose.debug.js"></script>
66
</head>
77
<body>
88
<script>
9-
console.log( window.mongoose );
9+
//console.log( window.mongoose );
1010

11+
function syncValidator (val) {
12+
console.log( 'syncValidator', val == 'sync' );
13+
return val == 'sync';
14+
}
15+
16+
function asyncValidator (val, respond) {
17+
console.log( 'asyncValidator', val == 'nick' );
18+
setTimeout(function( ){
19+
respond( val == 'nick' );
20+
console.warn( doc.$__.validationError );
21+
}, 0);
22+
}
23+
24+
var sync = [syncValidator, 'Uh oh, {PATH} does not equal "sync".'];
25+
var async = [asyncValidator, 'failed'];
26+
27+
var sub = new mongoose.Schema({
28+
title: { type: String, required: true },
29+
sync: { type: String, /*required: true,*/ validate: sync },
30+
async: { type: String, /*required: true,*/ validate: async }
31+
});
1132
var schema = new mongoose.Schema({
12-
prop: { type: String, required: true },
13-
nick: { type: String, required: true }
33+
mike: { type: String, required: true },
34+
sync: { type: String, /*required: true,*/ validate: sync },
35+
async: { type: String, /*required: true,*/ validate: async },
36+
subs: [ sub ]
1437
});
38+
39+
var doc = new mongoose.Document({
40+
//mike: 'sdf',
41+
sync: 'syn',
42+
async: 'asd',
43+
subs: [{
44+
45+
},{
46+
47+
}]
48+
}, schema);
49+
50+
/*doc.validate(function( err ){
51+
console.log( err );
52+
});*/
53+
var err = doc.validateSync();
54+
55+
console.info( err );
56+
console.log( err.errors.mike );
57+
console.log( err.errors.sync );
58+
console.log( err.errors.async );
59+
1560
</script>
1661
</body>
1762
</html>

0 commit comments

Comments
 (0)