<commit_before>import { expect } from 'chai';
import validator from '../../lib';

describe('regexp validator', () => {
  context('given null value', () => {
    const rules = {
      name: ['regex:42:g']
    };
    const result = validator.validate(rules, {name: null});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
    expect(err).to.not.have.property('name');
    });
  });

  context('given undefined value', () => {
    const rules = {
      name: ['regex:42:g']
    };
    const result = validator.validate(rules, {name: undefined});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
    expect(err).to.not.have.property('name');
    });
  });

  context('given value that matches the pattern non digit', () => {
    const rules = {
      name: ['regex:\\D:g']
    };
    const result = validator.validate(rules, {name: 'halo'});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
      expect(err).to.not.have.property('name');
    });
  });

  context('given value that does not match the pattern non digit', () => {
    const rules = {<commit_msg>change testcase to validate empty object<commit_after>import { expect } from 'chai';
import validator from '../../lib';

describe('regexp validator', () => {
  context('given null value', () => {
    const rules = {
      name: ['regex:42:g']
    };
    const result = validator.validate(rules, {name: null});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
    expect(err).to.not.have.property('name');
    });
  });

  context('given undefined value', () => {
    const rules = {
      name: ['regex:42:g']
    };
    const result = validator.validate(rules, {});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
    expect(err).to.not.have.property('name');
    });
  });

  context('given value that matches the pattern non digit', () => {
    const rules = {
      name: ['regex:\\D:g']
    };
    const result = validator.validate(rules, {name: 'halo'});
    const err = result.messages;

    it('should success', () => {
      expect(result.success).to.equal(true);
      expect(err).to.not.have.property('name');
    });
  });

  context('given value that does not match the pattern non digit', () => {
    const rules = {
{'fraction_non_alphanumeric': 0.1906474820143885, 'fraction_numerical': 0.0031974420463629096, 'mean_word_length': 2.9541864139020535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2204357', 'n_tokens_mistral': 788, 'n_tokens_neox': 763, 'n_words': 171}