<commit_before>var _ = require('underscore');
var lib = require('./lib');
var errors = require('./errors');

/**
 * Validates that a number is a valid length (positive number)
 *
 * @params: {number} num - Number to validate
 */
_validateLength = function(num) {
  if(!num || typeof num != 'number' || num < 0) {
    throw new Error(errors.length);
  }
};

/**
 * Registers the properties of a password-validation schema object
 *
 * @params: {string} func - Property name
 * @params: {array} args - arguments for the func property
 */
var _register = function(func, args) {
  // Add property to the schema
  this.properties.push({ method: func, arguments: args });
  return this;
};

/**
 * Constructor to create a password-validator object
 */
var Schema = function() {
  // Initialize a schema with no properties defined
  this.properties = [];
  return this;
};

/**
 * Method to validate the password against schema
 *
 * @params: {string} pwd - <PASSWORD>
 */
Schema.prototype.validate = function(pwd) {
  // Checks if pwd is invalid
  if(!pwd || typeof pwd != 'string') {
    throw new Error(errors.password);
  }

  // Sets password string
  this.password = <PASSWORD>;

  // Sets that no inversion takes place by default
  this.positive = true;

  // A password without any validation check is valid by default
  this.valid = true;

  var self = this;

  // Sets valid property after applying all validations
  _.reduce(self.properties, function(valid, property) {
    // Applies all validations defined in lib one by one
    return lib[property.method].apply(self, property.arguments);
  }, self.valid);

  return this.valid;
};

/**
 * Method to invert the next validations
 */
Schema.prototype.not = function() {
  return _register.call(this, 'not', arguments);
};

/**
 * Method to invert the effects of not()
 */
Schema.prototype.has = function() {
  return _register.call(this, 'has', arguments);
};

/**
 * Method to specify a minimum length
 *
 * @params: num - minimum length
 */
Schema.prototype.isMin = function(num) {
  _validateLength(num);
  return _register.call(this, 'isMin', arguments);
};

/**
 * Method to specify a maximum length
 *
 * @params: num - maximum length
 */
Schema.prototype.isMax = function(num) {
  _validateLength(num);
  return _register.call(this, 'isMax', arguments);
}

/**
 * Method to validate the presense of digits
 */
Schema.prototype.digits = function() {
  return _register.call(this, 'digits', arguments);
};

/**
 * Method to validate the presense of letters
 */
Schema.prototype.letters = function() {
 return _register.call(this, 'letters', arguments);
};

/**
 * Method to validate the presense of uppercase letters
 */
Schema.prototype.uppercase = function() {
  return _register.call(this, 'uppercase', arguments);
};

/**
 * Method to validate the presense of lowercase letters
 */
Schema.prototype.lowercase = function() {
  return _register.call(this, 'lowercase', arguments);
};

/**
 * Method to validate the presense of symbols
 */
Schema.prototype.symbols = function() {
  return _register.call(this, 'symbols', arguments);
};

/**
 * Method to validate the presense of space
 */
Schema.prototype.spaces = function() {
return _register.call(this, 'spaces', arguments);
};

module.exports = Schema;<commit_msg>Renames Schema class to PasswordSchema<commit_after>var _ = require('underscore');
var lib = require('./lib');
var errors = require('./errors');

/**
 * Validates that a number is a valid length (positive number)
 *
 * @params: {number} num - Number to validate
 */
_validateLength = function(num) {
  if(!num || typeof num != 'number' || num < 0) {
    throw new Error(errors.length);
  }
};

/**
 * Registers the properties of a password-validation schema object
 *
 * @params: {string} func - Property name
 * @params: {array} args - arguments for the func property
 */
var _register = function(func, args) {
  // Add property to the schema
  this.properties.push({ method: func, arguments: args });
  return this;
};

/**
 * Constructor to create a password-validator object
 */
var PasswordSchema = function() {
  // Initialize a schema with no properties defined
  this.properties = [];
  return this;
};

/**
 * Method to validate the password against schema
 *
 * @params: {string} pwd - password to valdiate
 */
PasswordSchema.prototype.validate = function(pwd) {
  // Checks if pwd is invalid
  if(!pwd || typeof pwd != 'string') {
    throw new Error(errors.password);
  }

  // Sets password string
  this.password = <PASSWORD>;

  // Sets that no inversion takes place by default
  this.positive = true;

  // A password without any validation check is valid by default
  this.valid = true;

  var self = this;

  // Sets valid property after applying all validations
  _.reduce(self.properties, function(valid, property) {
    // Applies all validations defined in lib one by one
    return lib[property.method].apply(self, property.arguments);
  }, self.valid);

  return this.valid;
};

/**
 * Method to invert the next validations
 */
PasswordSchema.prototype.not = function() {
  return _register.call(this, 'not', arguments);
};

/**
 * Method to invert the effects of not()
 */
PasswordSchema.prototype.has = function() {
  return _register.call(this, 'has', arguments);
};

/**
 * Method to specify a minimum length
 *
 * @params: num - minimum length
 */
PasswordSchema.prototype.isMin = function(num) {
  _validateLength(num);
  return _register.call(this, 'isMin', arguments);
};

/**
 * Method to specify a maximum length
 *
 * @params: num - maximum length
 */
PasswordSchema.prototype.isMax = function(num) {
  _validateLength(num);
  return _register.call(this, 'isMax', arguments);
}

/**
 * Method to validate the presense of digits
 */
PasswordSchema.prototype.digits = function() {
  return _register.call(this, 'digits', arguments);
};

/**
 * Method to validate the presense of letters
 */
PasswordSchema.prototype.letters = function() {
 return _register.call(this, 'letters', arguments);
};

/**
 * Method to validate the presense of uppercase letters
 */
PasswordSchema.prototype.uppercase = function() {
  return _register.call(this, 'uppercase', arguments);
};

/**
 * Method to validate the presense of lowercase letters
 */
PasswordSchema.prototype.lowercase = function() {
  return _register.call(this, 'lowercase', arguments);
};

/**
 * Method to validate the presense of symbols
 */
PasswordSchema.prototype.symbols = function() {
  return _register.call(this, 'symbols', arguments);
};

/**
 * Method to validate the presense of space
 */
PasswordSchema.prototype.spaces = function() {
return _register.call(this, 'spaces', arguments);
};

module.exports = PasswordSchema;
{'fraction_non_alphanumeric': 0.1346871733612065, 'fraction_numerical': 0.00029864118261908315, 'mean_word_length': 3.836101083032491, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '1703817', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1911, 'n_words': 629}