object check module using should.js


node.js object check module using should.js

You can check objects format (for example test cases..)

var check = require('should-check');
var obj = {
  Model: ['prop1'],
  List: [':[Model]'],
  ModelListObj: ['list:[Model]']
var sc = check.init(obj);
sc.check('Model', {prop1: 'val1'});
sc.check('List', [{prop1: 'val1'}]);
sc.check('ModelListObj', {list: [{prop1: 'val1'}]});
var json = sc.checkJSON('Model', '{"prop1": "val1"}');

initialize and return SC object

compare target_obj and name of object

parse json_str and compare the json and name of object. Also return the parsed json object.