<commit_before>'use strict';

angular.module('validacionesApp')
  .directive('validateForm', function () {
    return {
      restrict: 'A',
      require: '?ngModel',
      scope: {
        'validateForm':'=',
        'onValid': '&',
        'onInvalid': '&'
      },
      link: function link(scope, element) {
        function checkForm(){
          var errors = {}, hayErrores = false;
          for(var key in scope.validateForm){
            if (key.indexOf('$') !== 0) {
              if (scope.validateForm[key].$invalid) {
                hayErrores = true;
                errors[key] = scope.validateForm[key];
              }
            }
          }
          console.log(errors);
          if (hayErrores){
            scope.onInvalid({currentErrors: errors});
          } else {
            scope.onValid();
          }

        }
        angular.element(element).on('click',checkForm);
        scope.$on('destroy', function (){
          angular.element(element).off('click', checkForm);<commit_msg>ejercicio 14: simplificada directiva de validateform<commit_after>'use strict';

angular.module('validacionesApp')
  .directive('validateForm', function () {
    return {
      restrict: 'A',
      require: '?ngModel',
      scope: {
        'validateForm':'=',
        'onValid': '&',
        'onInvalid': '&'
      },
      link: function link(scope, element) {
        function checkForm(){
          if (scope.validateForm.$valid) {
            scope.onValid();
            return;
          }
          var errors = {};
          for(var key in scope.validateForm){
            if (key.indexOf('$') !== 0) {
              if (scope.validateForm[key].$invalid) {
                errors[key] = scope.validateForm[key];
              }
            }
          }
          scope.onInvalid({currentErrors:errors});
        }
        angular.element(element).on('click',checkForm);
        scope.$on('destroy', function (){
          angular.element(element).off('click', checkForm);
{'fraction_non_alphanumeric': 0.15165165165165165, 'fraction_numerical': 0.002002002002002002, 'mean_word_length': 1.8194640338504937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3853952', 'n_tokens_mistral': 560, 'n_tokens_neox': 550, 'n_words': 96}