function validateObjectRequired(options, modelObject, entity, parents, errors) {
  for (var key in modelObject) {
    if (!modelObject[key].type && entity) {
      validateObjectRequired(
        options,
        modelObject[key],
        entity[key],
        parents + '.' + key,
        errors);
    } else if (!options.notRequired && modelObject[key].required && (!entity || !entity[key])) {
      if (!errors.notFound) errors.notFound = [];
      var fieldName = parents + '.' + key;
      errors.notFound.push(fieldName);
      errors.text.push('Field ' + fieldName + ' not found');
    }
  }

  return errors;
}
function validateObjectRequired(options, modelObject, entity, parents, errors) {
  for (var key in modelObject) {
    if (!modelObject[key].type && entity) {
      validateObjectRequired(
        options,
        modelObject[key],
        entity[key],
        parents + '.' + key,
        errors);
    } else if (!options.notRequired && modelObject[key].required && (!entity || !entity[key])) {
      if (!errors.notFound) errors.notFound = [];
      var fieldName = parents + '.' + key;
      errors.notFound.push(fieldName);
      errors.text.push('Field ' + fieldName + ' not found');
    }
  }

  return errors;
}
function validateObjectRequired ( options , modelObject , entity , parents , errors ) { for ( var key in modelObject ) { if ( ! modelObject [ key ] . type && entity ) { validateObjectRequired ( options , modelObject [ key ] , entity [ key ] , parents + '.' + key , errors ) ; } else if ( ! options . notRequired && modelObject [ key ] . required && ( ! entity || ! entity [ key ] ) ) { if ( ! errors . notFound ) errors . notFound = [ ] ; var fieldName = parents + '.' + key ; errors . notFound . push ( fieldName ) ; errors . text . push ( 'Field ' + fieldName + ' not found' ) ; } } return errors ; }
check for required fields recursively
check for required fields recursively