index.js
function (modelName, entity, options, next) {
    if (typeof options === 'function') next = options;
    if (!options) options = {};

    var modelObject = this.registeredModels[modelName];

    if (typeof modelName === 'object') {
      modelObject = deepLook(modelName, this.types);
    } else if (this.types[modelName]) {
      if (options.one) this.types[modelName].one = options.one;
      var result = this.types[modelName].check(entity) ? null : { notMatched: modelName };
      return typeof next === 'function' ? next(result) : result;
    }

    var errors = validateObjectRequired(
      options, modelObject, entity, [],
      validateObjectEntity(modelObject, entity)
    );
    if (!errors.text[0]) errors = {};
    if (errors && errors.text) errors.text = errors.text.join('. ');

    if (typeof next === 'function') {
      next(Object.keys(errors).length ? errors : null);
    } else {
      return Object.keys(errors).length ? errors : {};
    }
  }
function (modelName, entity, options, next) {
    if (typeof options === 'function') next = options;
    if (!options) options = {};

    var modelObject = this.registeredModels[modelName];

    if (typeof modelName === 'object') {
      modelObject = deepLook(modelName, this.types);
    } else if (this.types[modelName]) {
      if (options.one) this.types[modelName].one = options.one;
      var result = this.types[modelName].check(entity) ? null : { notMatched: modelName };
      return typeof next === 'function' ? next(result) : result;
    }

    var errors = validateObjectRequired(
      options, modelObject, entity, [],
      validateObjectEntity(modelObject, entity)
    );
    if (!errors.text[0]) errors = {};
    if (errors && errors.text) errors.text = errors.text.join('. ');

    if (typeof next === 'function') {
      next(Object.keys(errors).length ? errors : null);
    } else {
      return Object.keys(errors).length ? errors : {};
    }
  }
function ( modelName , entity , options , next ) { if ( typeof options === 'function' ) next = options ; if ( ! options ) options = { } ; var modelObject = this . registeredModels [ modelName ] ; if ( typeof modelName === 'object' ) { modelObject = deepLook ( modelName , this . types ) ; } else if ( this . types [ modelName ] ) { if ( options . one ) this . types [ modelName ] . one = options . one ; var result = this . types [ modelName ] . check ( entity ) ? null : { notMatched : modelName } ; return typeof next === 'function' ? next ( result ) : result ; } var errors = validateObjectRequired ( options , modelObject , entity , [ ] , validateObjectEntity ( modelObject , entity ) ) ; if ( ! errors . text [ 0 ] ) errors = { } ; if ( errors && errors . text ) errors . text = errors . text . join ( '. ' ) ; if ( typeof next === 'function' ) { next ( Object . keys ( errors ) . length ? errors : null ) ; } else { return Object . keys ( errors ) . length ? errors : { } ; } }
Check if entity pass modelName's validation
Check if entity pass modelName s validation