src/browser/schemaValidator.js
function validateModel(json, model) {
    var schemaKeys = [];
    for (var keyInSchema in model) {
      schemaKeys.push(keyInSchema);
    }
    // Check if foreing keys are allowed.
    if (!model[SCHEMAALLOWUNKNOWN]) {
      // TODO ensure that null and false enter here.
      checkUnknown(json, schemaKeys);
    }
    for (var schemaKeyI = 0; schemaKeyI < schemaKeys.length; schemaKeyI++) {
      var node = null;
      var schemaKey = schemaKeys[schemaKeyI];
      if (json[schemaKey]) {
        node = json[schemaKey];
      }
      if (!isReservedWord(schemaKey)) {
        validateNode(node, model[schemaKey], schemaKey);
      }
    }
  }
function validateModel(json, model) {
    var schemaKeys = [];
    for (var keyInSchema in model) {
      schemaKeys.push(keyInSchema);
    }
    // Check if foreing keys are allowed.
    if (!model[SCHEMAALLOWUNKNOWN]) {
      // TODO ensure that null and false enter here.
      checkUnknown(json, schemaKeys);
    }
    for (var schemaKeyI = 0; schemaKeyI < schemaKeys.length; schemaKeyI++) {
      var node = null;
      var schemaKey = schemaKeys[schemaKeyI];
      if (json[schemaKey]) {
        node = json[schemaKey];
      }
      if (!isReservedWord(schemaKey)) {
        validateNode(node, model[schemaKey], schemaKey);
      }
    }
  }
function validateModel ( json , model ) { var schemaKeys = [ ] ; for ( var keyInSchema in model ) { schemaKeys . push ( keyInSchema ) ; } // Check if foreing keys are allowed. if ( ! model [ SCHEMAALLOWUNKNOWN ] ) { // TODO ensure that null and false enter here. checkUnknown ( json , schemaKeys ) ; } for ( var schemaKeyI = 0 ; schemaKeyI < schemaKeys . length ; schemaKeyI ++ ) { var node = null ; var schemaKey = schemaKeys [ schemaKeyI ] ; if ( json [ schemaKey ] ) { node = json [ schemaKey ] ; } if ( ! isReservedWord ( schemaKey ) ) { validateNode ( node , model [ schemaKey ] , schemaKey ) ; } } }
Validate model. Mode is an object in the schema, it can be root node or an object inside it.
@param  {[type]} json  [description]
@param  {[type]} model [description]
@return {[type]}       [description]
Validate model . Mode is an object in the schema it can be root node or an object inside it .