<commit_before>'use strict';

const MessageValidationBlinkError = require('../../src/errors/MessageValidationBlinkError');

class MessageValidationHelper {

  static mutate({ remove, change, value, message }) {
    const mutant = message;
    if (remove) {
      delete mutant.payload.data[remove];
      return mutant;
    }
    if (change) {
      mutant.payload.data[change] = value;
      return mutant;
    }
    return false;
  }

  static failsWithout(fieldName, generator) {
    let mutant;
    mutant = MessageValidationHelper.mutate({ remove: fieldName, message: generator() });
    mutant.validateStrict.should.throw(MessageValidationBlinkError, `"${fieldName}" is required`);

    // TODO: validate null, undefined, empty string
  }

  static removesWhenEmpty(fieldName, generator) {
    let mutant;

    mutant = MessageValidationHelper.mutate({
      change: fieldName,
      value: '',
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.not.have.property(fieldName);

    mutant = MessageValidationHelper.mutate({
      change: fieldName,
      value: null,
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.not.have.property(fieldName);
  }

  static defaultToNullWhenEmpty(fieldName, generator) {
    const mutant;

    mutant = MessageValidationHelper.mutate({
      remove: fieldName,
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.have.property(fieldName).and.be.equal(null);
  }

}

module.exports = MessageValidationHelper;<commit_msg>Parsing error fix<commit_after>'use strict';

const MessageValidationBlinkError = require('../../src/errors/MessageValidationBlinkError');

class MessageValidationHelper {

  static mutate({ remove, change, value, message }) {
    const mutant = message;
    if (remove) {
      delete mutant.payload.data[remove];
      return mutant;
    }
    if (change) {
      mutant.payload.data[change] = value;
      return mutant;
    }
    return false;
  }

  static failsWithout(fieldName, generator) {
    let mutant;
    mutant = MessageValidationHelper.mutate({ remove: fieldName, message: generator() });
    mutant.validateStrict.should.throw(MessageValidationBlinkError, `"${fieldName}" is required`);

    // TODO: validate null, undefined, empty string
  }

  static removesWhenEmpty(fieldName, generator) {
    let mutant;

    mutant = MessageValidationHelper.mutate({
      change: fieldName,
      value: '',
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.not.have.property(fieldName);

    mutant = MessageValidationHelper.mutate({
      change: fieldName,
      value: null,
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.not.have.property(fieldName);
  }

  static defaultToNullWhenEmpty(fieldName, generator) {
    const mutant = MessageValidationHelper.mutate({
      remove: fieldName,
      message: generator(),
    });
    mutant.validateStrict();
    mutant.getData().should.have.property(fieldName).and.be.equal(null);
  }

}

module.exports = MessageValidationHelper;
{'fraction_non_alphanumeric': 0.12472371329333755, 'fraction_numerical': 0.0, 'mean_word_length': 3.4682651622002822, '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': '2387099', 'n_tokens_mistral': 922, 'n_tokens_neox': 897, 'n_words': 180}