<commit_before>import Ember from 'ember';
import Errors from 'ember-validator/errors';
import Validator from 'ember-validator/validators/validator';


export default Ember.Mixin.create({
  validate: function(props) {
    var rules = this.get('validations') || props.validations;

    return this.validateMap({
      object: this,
      validations: rules,
      noPromise: props.noPromise
    });
  },

  validateMap: function(props) {
    var self = this;
    var noPromise = props.noPromise;

    var doValidate = function(props) {
      var object = props.model;
      var validations = props.validations;
      var result = Errors.create();
      var allErrors = Ember.A();
      var allValidators = Ember.A();
      var rules;
      var rule;
      var property;
      var errors;
      var validationResult;

      if (object && validations) {<commit_msg>Computed validations<commit_after>import Ember from 'ember';
import Errors from 'ember-validator/errors';
import Validator from 'ember-validator/validators/validator';


export default Ember.Mixin.create({
  validate: function(props) {
    var rules = this.get('validations') || props.validations;

    return this.validateMap({
      model: this,
      validations: rules,
      noPromise: props.noPromise
    });
  },

  computedValidateMap: function(props) {
    var object = props.model;
    var validations = props.validations;
    var self = this;

    for (var key in object) {
      if (key.indexOf('ValidatorResult') !== -1 || key.indexOf('ValidatorPreviousVal') != -1) {
        object.set(key, null);
      }
    }

    for (var property in validations) {
      object.set(property + 'ValidatorPreviousVal', object.get(property));
      Ember.defineProperty(object, property + 'ValidatorResult', Ember.computed(property, function(sender) {
        var rules = {};
        var prop = sender.replace('ValidatorResult', '');
        var result;

        if (object.get(prop) !== object.get(prop + 'ValidatorPreviousVal')) {
          rules[prop] = validations[prop];

          result = self.validateMap({
            model: object,
            validations: rules,
            noPromise: true
          });
        }

        return result;
      }));
    }
  },

  validateMap: function(props) {
    var self = this;
    var noPromise = props.noPromise;

    var doValidate = function(props) {
      var object = props.model;
      var validations = props.validations;
      var result = Errors.create();
      var allErrors = Ember.A();
      var allValidators = Ember.A();
      var rules;
      var rule;
      var property;
      var errors;
      var validationResult;

      if (object && validations) {
{'fraction_non_alphanumeric': 0.11720791340052258, 'fraction_numerical': 0.0007465472191116088, 'mean_word_length': 2.6363636363636362, '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': '1300552', 'n_tokens_mistral': 769, 'n_tokens_neox': 763, 'n_words': 196}