<commit_before>EmberUI.ValidationSupport = Ember.Mixin.create({
  computedErrorState: null,
  computedErrorMessage: null,

  validateField: function(type) {
    var hasError = this.get('hasError');
    var errorMessage = this.get('errorMessage');
    var required = this.get('required');
    var value = this.get('value');

    if (type === 'onload' && value === null) return;

    if (hasError || errorMessage || (required && !value)) {
      this.set('computedErrorState', true);

      // Because hasError can either be true or contain an error message we need to check which it is
      if (hasError && typeof(hasError) !== 'boolean' ) {
        this.set('computedErrorMessage', hasError);

      } else if (errorMessage) {
        this.set('computedErrorMessage', errorMessage);
      }

    } else {
      this.set('computedErrorState', false);
      this.set('computedErrorMessage', null);
    }
  },

  focusOut: function() {
    this.validateField();
  },

  onChange: function() {
    if (this.get('computedErrorState')) Ember.run.once(this, 'validateField');
  }.observes('value'),

  validateOnLoad: function() {
    this.validateField('onload');
  }.on('init')
});
<commit_msg>support sending error messages in array format<commit_after>EmberUI.ValidationSupport = Ember.Mixin.create({
  computedErrorState: null,
  computedErrorMessage: null,

  validateField: function(type) {
    var hasError = this.get('hasError');
    var errorMessage = this.get('errorMessage');
    var required = this.get('required');
    var value = this.get('value');

    if (type === 'onload' && value === null) return;

    // We only ever show one error message at a time
    if ($.isArray([hasError])) {
      hasError = hasError[0];
    }

    if (hasError || errorMessage || (required && !value)) {
      this.set('computedErrorState', true);

      // Because hasError can either be true or contain an error message we need to check which it is
      if (hasError && typeof(hasError) !== 'boolean' ) {
        this.set('computedErrorMessage', hasError);

      } else if (errorMessage) {
        this.set('computedErrorMessage', errorMessage);
      }

    } else {
      this.set('computedErrorState', false);
      this.set('computedErrorMessage', null);
    }
  },

  focusOut: function() {
    this.validateField();
  },

  onChange: function() {
    if (this.get('computedErrorState')) Ember.run.once(this, 'validateField');
  }.observes('value'),

  validateOnLoad: function() {
    this.validateField('onload');
  }.on('init')
});

{'fraction_non_alphanumeric': 0.15141955835962145, 'fraction_numerical': 0.0003943217665615142, 'mean_word_length': 3.4275741710296685, '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': '2479729', 'n_tokens_mistral': 767, 'n_tokens_neox': 750, 'n_words': 182}