Skip to content

Instantly share code, notes, and snippets.

@dvv
Created October 6, 2010 05:04
Show Gist options
  • Save dvv/612860 to your computer and use it in GitHub Desktop.
Save dvv/612860 to your computer and use it in GitHub Desktop.
#!/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