<commit_before>import Ember from 'ember';
import layout from '../templates/components/validated-input';

/**
 * This component wraps form inputs.
 *
 * It can be used in a two-way-binding style like
 * {{validated-input model=model name='firstName'}} (model will be updated)
 *
 * or in a one-way-binding style
 * {{validated-input model=model name='firstName' on-update=(action "update"}}
 * (update action is called, model is not updated)
 */
export default Ember.Component.extend({
  layout,

  dirty: false,

  required: false,

  type: 'input',

  classNameBindings: ['dirty', 'config.css.group', 'validationClass'],

  validationClass: Ember.computed('showError', function() {
    const errorClass = this.get('config.css.error') || 'has-error';
    const validClass = this.get('config.css.valid') || 'valid';

    return this.get('showError') ? errorClass : validClass;
  }),

  error: Ember.computed('model.error', function() {
    const error = this.get('model.error');
    return error ? error[this.get('name')] : null;
  }),

  isValid: Ember.computed('error', function() {
    return !this.get('error');
  }),

  firstError: Ember.computed('error', function() {
    return this.get('error.validation')[0];
  }),

  showError: Ember.computed('isValid', 'dirty', 'submitted', function() {
    return !this.get('isValid') && (this.get('dirty') || this.get('submitted'));
  }),

  requiredLabel: Ember.computed('config', function() {
    return this.get('config.label.required') || '*';
  }),

  actions: {
    setDirty() {
      this.set('dirty', true);<commit_msg>only select first if its an array<commit_after>import Ember from 'ember';
import layout from '../templates/components/validated-input';

/**
 * This component wraps form inputs.
 *
 * It can be used in a two-way-binding style like
 * {{validated-input model=model name='firstName'}} (model will be updated)
 *
 * or in a one-way-binding style
 * {{validated-input model=model name='firstName' on-update=(action "update"}}
 * (update action is called, model is not updated)
 */
export default Ember.Component.extend({
  layout,

  dirty: false,

  required: false,

  type: 'input',

  classNameBindings: ['dirty', 'config.css.group', 'validationClass'],

  validationClass: Ember.computed('showError', function() {
    const errorClass = this.get('config.css.error') || 'has-error';
    const validClass = this.get('config.css.valid') || 'valid';

    return this.get('showError') ? errorClass : validClass;
  }),

  error: Ember.computed('model.error', function() {
    const error = this.get('model.error');
    return error ? error[this.get('name')] : null;
  }),

  isValid: Ember.computed('error', function() {
    return !this.get('error');
  }),

  firstError: Ember.computed('error', function() {
    const errors = this.get('error.validation');
    return Ember.isArray(errors) ? errors[0] : errors;
  }),

  showError: Ember.computed('isValid', 'dirty', 'submitted', function() {
    return !this.get('isValid') && (this.get('dirty') || this.get('submitted'));
  }),

  requiredLabel: Ember.computed('config', function() {
    return this.get('config.label.required') || '*';
  }),

  actions: {
    setDirty() {
      this.set('dirty', true);
{'fraction_non_alphanumeric': 0.1782393056416615, 'fraction_numerical': 0.0006199628022318661, 'mean_word_length': 4.171474358974359, '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': '2869055', 'n_tokens_mistral': 1020, 'n_tokens_neox': 996, 'n_words': 238}