<commit_before>import Ember from 'ember';

export default Ember.Mixin.create({
  initEmberComputedValidations: Ember.on('init', function() {
    if(!this.computedValidations) {
      return;
    }

    var validations = Ember.A();

    var properties = Object.keys(this.computedValidations);
    for (var i=0; i<properties.length; i++) {
      var property = properties[i];
      var validationsForProperty = Object.keys(this.computedValidations[property]);
      validations.pushObjects(validationsForProperty);
    }

    Ember.defineProperty(this, 'computedErrors', Ember.computed(...validations, function() {
      var _this = this;
      return Ember.Object.create({
        unknownProperty: function(property) {
          if(!_this.computedValidations[property]) {
            return [];
          }
          var validationsForProperty = Object.keys(_this.computedValidations[property]);
          return validationsForProperty.reduce(function(errorsForProperty, validationForProperty) {
            if (!_this.get(validationForProperty)) {
              errorsForProperty.push(_this.computedValidations[property][validationForProperty]);
            }
            return errorsForProperty;
          }, []);
        }
      });
    }));

    Ember.defineProperty(this, 'computedIsValid', Ember.computed(...validations, function() {
      return validations.every((validation)=> {
        return this.get(validation);
      });
    }));

    Ember.defineProperty(this, 'computedIsInvalid', Ember.computed.not('computedIsValid'));
  })
});
<commit_msg>Ember.A works better with #each loops<commit_after>import Ember from 'ember';

export default Ember.Mixin.create({
  initEmberComputedValidations: Ember.on('init', function() {
    if(!this.computedValidations) {
      return;
    }

    var validations = Ember.A();

    var properties = Object.keys(this.computedValidations);
    for (var i=0; i<properties.length; i++) {
      var property = properties[i];
      var validationsForProperty = Object.keys(this.computedValidations[property]);
      validations.pushObjects(validationsForProperty);
    }

    Ember.defineProperty(this, 'computedErrors', Ember.computed(...validations, function() {
      var _this = this;
      return Ember.Object.create({
        unknownProperty: function(property) {
          if(!_this.computedValidations[property]) {
            return Ember.A();
          }
          var validationsForProperty = Object.keys(_this.computedValidations[property]);
          return validationsForProperty.reduce(function(errorsForProperty, validationForProperty) {
            if (!_this.get(validationForProperty)) {
              errorsForProperty.push(_this.computedValidations[property][validationForProperty]);
            }
            return errorsForProperty;
          }, Ember.A());
        }
      });
    }));

    Ember.defineProperty(this, 'computedIsValid', Ember.computed(...validations, function() {
      return validations.every((validation)=> {
        return this.get(validation);
      });
    }));

    Ember.defineProperty(this, 'computedIsInvalid', Ember.computed.not('computedIsValid'));
  })
});

{'fraction_non_alphanumeric': 0.12682308180088775, 'fraction_numerical': 0.0006341154090044388, 'mean_word_length': 3.16776750330251, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2959794', 'n_tokens_mistral': 881, 'n_tokens_neox': 874, 'n_words': 137}