'use strict';

var fs = require('fs');
var isObject = require('isobject');
var Schema = require('./');

var schema = new Schema()
  .field('name', 'string')
  .field('description', 'string')
  .field('repository', ['object', 'string'], {
    normalize: function(val) {
      return isObject(val) ? val.url : val;
    }
  })
  .field('main', 'string', {
    validate: function(filepath) {
      console.log(filepath)
      return fs.existsSync(filepath);
    }
  })
  .field('version', 'string', {
    default: '0.1.0'
  })
  .field('license', 'string', {
    default: 'MIT'
  })

var pkg = require('./package');
console.log(schema.normalize(pkg));
console.log(schema.errors);

@@ -36,24 +36,22 @@
 ');%0Avar 
-isObject
+Schema
  = requi
@@ -58,48 +58,77 @@
 re('
-isobject');%0Avar Schema = require('./');%0A
+map-schema');%0Avar isObject = require('isobject');%0A%0A// create a schema
 %0Avar
@@ -412,36 +412,8 @@
 ) %7B%0A
-      console.log(filepath)%0A
     
@@ -604,16 +604,39 @@
 kage');%0A
+// normalize an object%0A
 console.
@@ -663,16 +663,43 @@
 (pkg));%0A
+// validation errors array%0A
 console.

comment examples