<commit_before>'use strict';

module.exports = function (options) {

  this.init(options);

};

module.exports.prototype = {

  init: function (options) {

    console.log("Init textline validation");

    this.validateMinLength = false;
    this.validateMaxLength = false;
    this.validateNoNumbers = false;
    this.validateMinNumbers = false;
    this.validateMaxNumbers = false;
    this.validateNoSpecialCharacters = false;
    this.validateMinSpecialCharacters = false;
    this.validateMaxSpecialCharacters = false;

    if (options.minLength) {
      this.minLength = options.minLength;
      this.validateMinLength = true;
    }

    if (options.maxLength) {
      this.maxLength = options.maxLength;
      this.validateMaxLength = true;
    }

    if (options.noNumbers) {
      this.validateNoNumbers = true;
    }

    if (options.minNumbers) {
      this.minNumbers = options.minNumbers;
      this.validateMinNumbers = true;
    }

    if (options.maxNumbers) {
      this.maxNumbers = options.maxNumbers;
      this.validateMaxNumbers = true;
    }

    if (options.noSpecialCharacters) {
      this.validateNoSpecialCharacters = true;
    }

    if (options.minSpecialCharacters) {
      this.minSpecialCharacters = options.minSpecialCharacters;
      this.validateMinSpecialCharacters = true;
    }

    if (options.maxSpecialCharacters) {
      this.maxSpecialCharacters = options.maxSpecialCharacters;
      this.validateMaxSpecialCharacters = true;
    }

  },

  setResult: function (passed, message) {

    this.result = {};

    this.result.passed = passed;

    if (message) {
      this.result.message = message;
    }

  },

  validateTextline: function (value) {

    this.setResult(true);
    this.value = value;

    if (this.validateMinLength) {
      this.checkMinLength();
    }

    if (this.validateMaxLength) {
      this.checkMaxLength();
    }

    if (this.validateNoNumbers) {
      this.checkNoNumbers();
    }

    if (this.validateMinNumbers) {
      this.checkMinNumbers();
    }

    if (this.validateMaxNumbers) {
      this.checkMaxNumbers();
    }

    if (this.validateNoSpecialCharacters) {
      this.checkNoSpecialCharacters();
    }

    if (this.validateMinSpecialCharacters) {
      this.checkMinSpecialCharacters();
    }

    if (this.validateMaxSpecialCharacters) {
      this.checkMaxSpecialCharacters();
    }

    return this.result;

  },

  checkMinLength: function () {

    if (this.value.length < this.minLength) {
      this.setResult(false, "Input is too short.");
    }

  },

  checkMaxLength: function () {

    if (this.value.length > this.maxLength) {
      this.setResult(false, "Input is too long.");
    }

  },

  checkNoNumbers: function () {

    var regExp = new RegExp("\\d");<commit_msg>Updated textline error messages<commit_after>'use strict';

module.exports = function (options) {

  this.init(options);

};

module.exports.prototype = {

  init: function (options) {

    console.log("Init textline validation");

    this.validateMinLength = false;
    this.validateMaxLength = false;
    this.validateNoNumbers = false;
    this.validateMinNumbers = false;
    this.validateMaxNumbers = false;
    this.validateNoSpecialCharacters = false;
    this.validateMinSpecialCharacters = false;
    this.validateMaxSpecialCharacters = false;

    if (options.minLength) {
      this.minLength = options.minLength;
      this.validateMinLength = true;
    }

    if (options.maxLength) {
      this.maxLength = options.maxLength;
      this.validateMaxLength = true;
    }

    if (options.noNumbers) {
      this.validateNoNumbers = true;
    }

    if (options.minNumbers) {
      this.minNumbers = options.minNumbers;
      this.validateMinNumbers = true;
    }

    if (options.maxNumbers) {
      this.maxNumbers = options.maxNumbers;
      this.validateMaxNumbers = true;
    }

    if (options.noSpecialCharacters) {
      this.validateNoSpecialCharacters = true;
    }

    if (options.minSpecialCharacters) {
      this.minSpecialCharacters = options.minSpecialCharacters;
      this.validateMinSpecialCharacters = true;
    }

    if (options.maxSpecialCharacters) {
      this.maxSpecialCharacters = options.maxSpecialCharacters;
      this.validateMaxSpecialCharacters = true;
    }

  },

  setResult: function (passed, message) {

    this.result = {};

    this.result.passed = passed;

    if (message) {
      this.result.message = message;
    }

  },

  validateTextline: function (value) {

    this.setResult(true);
    this.value = value;

    if (this.validateMinLength) {
      this.checkMinLength();
    }

    if (this.validateMaxLength) {
      this.checkMaxLength();
    }

    if (this.validateNoNumbers) {
      this.checkNoNumbers();
    }

    if (this.validateMinNumbers) {
      this.checkMinNumbers();
    }

    if (this.validateMaxNumbers) {
      this.checkMaxNumbers();
    }

    if (this.validateNoSpecialCharacters) {
      this.checkNoSpecialCharacters();
    }

    if (this.validateMinSpecialCharacters) {
      this.checkMinSpecialCharacters();
    }

    if (this.validateMaxSpecialCharacters) {
      this.checkMaxSpecialCharacters();
    }

    return this.result;

  },

  checkMinLength: function () {

    if (this.value.length < this.minLength) {
      this.setResult(false, "Input should be minimal " + this.minLength + " characters long.");
    }

  },

  checkMaxLength: function () {

    if (this.value.length > this.maxLength) {
      this.setResult(false, "Input can't be longer than " + this.maxLength + " characters.");
    }

  },

  checkNoNumbers: function () {

    var regExp = new RegExp("\\d");
{'fraction_non_alphanumeric': 0.11252879673932306, 'fraction_numerical': 0.0, 'mean_word_length': 2.803234501347709, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7148986', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1663, 'n_words': 292}