<commit_before>Acceptance.Field = Acceptance.Class({
  initialize: function(form, fieldName, message) {
    form._numRequirements += 1;
    this._form      = form;
    this._fieldName = fieldName;
    this._message   = message;
    this._tests     = [];
    this.getInput();
  },
  
  getInput: function() {
    if (this._hasInput()) return this._input;
    
    this._input = Acceptance.Dom.getInputs(this._form.getForm(), this._fieldName)[0];
    Acceptance.Event.on(this._input, 'blur', this._validate, this);
    
    return this._input;
  },
  
  setMessage: function(message) {
    if (!message) return;
    this._message = message;
  },
  
  addTest: function(test) {
    this._tests.push(test);
  },
  
  _hasInput: function() {
    return Acceptance.Dom.exists(this._input);
  },
  
  isValid: function(callback, scope) {
    this._validate(function() {
      callback.call(scope, !!this._valid);
    }, this);
  },
  
  _validate: function(callback, scope) {
    var tests    = this._tests.slice(),
        formData = Acceptance.Dom.getValues(this._form.getForm()),
        value    = formData[this._fieldName],
        errors   = [];
    
    if (tests.length === 0 || !Acceptance.trim(value))
      tests = [this.klass._isPresent(this._message)].concat(tests);
    
    var i = 0, n = tests.length, self = this;

    Acceptance.each(tests, function(test) {
      test(function(result) {
        if (result instanceof Array) errors = errors.concat(result);
<commit_msg>Adjust the way that presence tests are generated.<commit_after>Acceptance.Field = Acceptance.Class({
  initialize: function(form, fieldName, message) {
    form._numRequirements += 1;
    this._form      = form;
    this._fieldName = fieldName;
    this._tests     = [];
    this.getInput();
  },
  
  getInput: function() {
    if (this._hasInput()) return this._input;
    
    this._input = Acceptance.Dom.getInputs(this._form.getForm(), this._fieldName)[0];
    Acceptance.Event.on(this._input, 'blur', this._validate, this);
    
    return this._input;
  },
  
  setMessage: function(message) {
    if (!message) return;
    this.addTest(this.klass._isPresent(message));
  },
  
  addTest: function(test) {
    this._tests.push(test);
  },
  
  _hasInput: function() {
    return Acceptance.Dom.exists(this._input);
  },
  
  isValid: function(callback, scope) {
    this._validate(function() {
      callback.call(scope, !!this._valid);
    }, this);
  },
  
  _validate: function(callback, scope) {
    var tests    = this._tests.slice(),
        formData = Acceptance.Dom.getValues(this._form.getForm()),
        value    = formData[this._fieldName],
        errors   = [];
    
    var i = 0, n = tests.length, self = this;

    Acceptance.each(tests, function(test) {
      test(function(result) {
        if (result instanceof Array) errors = errors.concat(result);

{'fraction_non_alphanumeric': 0.1452064380685794, 'fraction_numerical': 0.00244926522043387, 'mean_word_length': 2.889795918367347, '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': '2181686', 'n_tokens_mistral': 913, 'n_tokens_neox': 906, 'n_words': 168}