<commit_before>import { AbstractControl, Validators } from '@angular/forms';
import { CreditCard } from './shared/credit-card';

export class CreditCardValidator {
  static validateCCNumber(control: AbstractControl): any {
    if (Validators.required(control) !== undefined && Validators.required(control) !== null) {
      return {'ccNumber': false};
    }

    let num = control.value.toString().replace(/\s+|-/g, '');

    if (!/^\d+$/.test(num)) {
      return {'ccNumber': false};
    }

    let card = CreditCard.cardFromNumber(num);

    if (!card) {
      return {'ccNumber': false};
    }

    if (card.length.includes(num.length) && (card.luhn === false || CreditCard.luhnCheck(num))) {
      return null;
    }

    return {'ccNumber': false};
  }

  static validateExpDate(control: AbstractControl): any {
    if (Validators.required(control) !== undefined && Validators.required(control) !== null) {
      return {'expDate': false };
    }

    if (typeof control.value !== 'undefined' && control.value.length >= 7) {
      let [month, year] = control.value.split(/[\s\/]+/, 2),
          prefix;

      if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
        prefix = new Date().getFullYear();
        prefix = prefix.toString().slice(0, 2);
        year = prefix + year;
      }
      month = parseInt(month, 10).toString();
      year  = parseInt(year, 10).toString();

      if (/^\d+$/.test(month) && /^\d+$/.test(year) && (month >= 1 && month <= 12)) {
        let currentTime, expiry;
        expiry = new Date(year, month);
        currentTime = new Date();
        expiry.setMonth(expiry.getMonth() - 1);
        expiry.setMonth(expiry.getMonth() + 1, 1);

        if (expiry > currentTime) {
          return null;
        }
      }
    }

    return {'expDate': false };

  }
}<commit_msg>chore: set returned  to true, matching angular validators<commit_after>import { AbstractControl, ValidationErrors, Validators } from '@angular/forms';
import { CreditCard } from './shared/credit-card';

export class CreditCardValidator {
  static validateCCNumber(control: AbstractControl): ValidationErrors|null {
    if (Validators.required(control) !== undefined && Validators.required(control) !== null) {
      return {'ccNumber': true};
    }

    let num = control.value.toString().replace(/\s+|-/g, '');

    if (!/^\d+$/.test(num)) {
      return {'ccNumber': true};
    }

    let card = CreditCard.cardFromNumber(num);

    if (!card) {
      return {'ccNumber': true};
    }

    if (card.length.includes(num.length) && (card.luhn === false || CreditCard.luhnCheck(num))) {
      return null;
    }

    return {'ccNumber': true};
  }

  static validateExpDate(control: AbstractControl): ValidationErrors|null {
    if (Validators.required(control) !== undefined && Validators.required(control) !== null) {
      return {'expDate': true };
    }

    if (typeof control.value !== 'undefined' && control.value.length >= 7) {
      let [month, year] = control.value.split(/[\s\/]+/, 2),
          prefix;

      if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
        prefix = new Date().getFullYear();
        prefix = prefix.toString().slice(0, 2);
        year = prefix + year;
      }
      month = parseInt(month, 10).toString();
      year  = parseInt(year, 10).toString();

      if (/^\d+$/.test(month) && /^\d+$/.test(year) && (month >= 1 && month <= 12)) {
        let currentTime, expiry;
        expiry = new Date(year, month);
        currentTime = new Date();
        expiry.setMonth(expiry.getMonth() - 1);
        expiry.setMonth(expiry.getMonth() + 1, 1);

        if (expiry > currentTime) {
          return null;
        }
      }
    }

    return {'expDate': true };

  }
}
{'fraction_non_alphanumeric': 0.17860934182590232, 'fraction_numerical': 0.008492569002123142, 'mean_word_length': 2.6521317829457365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1050036', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1136, 'n_words': 262}