Created
October 6, 2010 05:04
-
-
Save dvv/612860 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env node | |
require.paths.unshift(__dirname + '/lib/node', __dirname); | |
var sys = require('sys'); | |
var oldconsolelog = console.log; | |
console.log = function(){ | |
Array.prototype.forEach.call(arguments, function(arg){ | |
if (arg instanceof Object) | |
arg = sys.inspect(arg, false, null); | |
oldconsolelog(arg); | |
}); | |
} | |
var assert = require('assert'), | |
Schema = require('schema'); | |
var result, errors; | |
var model = {}; | |
model.Language = Schema.create({ | |
type: 'object', | |
id: 'Language', | |
properties: { | |
id: {type: 'string'}, | |
name: {type: 'string'} | |
} | |
}); | |
var schema = Schema.create({ | |
type: 'object', | |
id: 'User', | |
properties: { | |
lang: {$ref: 'Language.id'} | |
} | |
}); | |
//console.log(Object.keys(Schema.instances)); | |
Schema.resolveRefs(); | |
object = { | |
lang: 'en' | |
}; | |
console.log('ORIG', object); | |
validation = schema.validate(object); | |
console.log('VALIDATED', object, validation.errors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment