<commit_before>'use strict';

import fs from 'fs';
import path from 'path';
import Platform from '../services/platform';

let pathWindowsRegex = /^[a-zA-Z]:\\(?:[^#%\\/:*?"<>|\r\n]+\\)*[^#%\\/:*?"<>|\r\n]*$/;
let nonAsciiRegex = /[^\x00-\x7F]+/;

function pathValidator() {
  return {
    require: 'ngModel',
    link: function(scope, element, attr, mCtrl) {

      function validateFormatWindows(value) {
        return pathWindowsRegex.test(value);
      }

      function validateAscii(value) {
        return !nonAsciiRegex.test(value);
      }

      function validateLength(value) {
        return value.length<=90;
      }

      function hasNoSpaces(value) {
        return !value.includes(' ');
      }

      function validateDisk(value) {
        let stats = path.parse(value);
        return !stats.root.length == 0 && fs.existsSync(stats.root);
      }

      function isSelected(value) {
        return value.trim().length>0;
      }

      function isAbsolute(value) {
        return path.isAbsolute(value);
      }

      mCtrl.$validators['notSelected'] = isSelected;
      mCtrl.$validators['notAbsolute'] = isAbsolute;
      mCtrl.$validators['tooLong'] = validateLength;
      //mCtrl.$validators['hasSpaces'] = hasNoSpaces;
      if(Platform.OS == 'win32') {
        mCtrl.$validators['invalidAscii'] = validateAscii;
        mCtrl.$validators['invalidFormat'] = validateFormatWindows;
        mCtrl.$validators['invalidDisk'] = validateDisk;
      }
    }
  };
}

export default pathValidator;
<commit_msg>JBDS-4334 Remove unused path validators<commit_after>'use strict';

import fs from 'fs';
import path from 'path';
import Platform from '../services/platform';

let pathWindowsRegex = /^[a-zA-Z]:\\(?:[^#%\\/:*?"<>|\r\n]+\\)*[^#%\\/:*?"<>|\r\n]*$/;
let nonAsciiRegex = /[^\x00-\x7F]+/;

function pathValidator() {
  return {
    require: 'ngModel',
    link: function(scope, element, attr, mCtrl) {

      function validateFormatWindows(value) {
        return pathWindowsRegex.test(value);
      }

      function validateAscii(value) {
        return !nonAsciiRegex.test(value);
      }

      function validateLength(value) {
        return value.length<=90;
      }

      function validateDisk(value) {
        let stats = path.parse(value);
        return !stats.root.length == 0 && fs.existsSync(stats.root);
      }

      function isSelected(value) {
        return value.trim().length>0;
      }

      function isAbsolute(value) {
        return path.isAbsolute(value);
      }

      mCtrl.$validators['notSelected'] = isSelected;
      mCtrl.$validators['notAbsolute'] = isAbsolute;
      mCtrl.$validators['tooLong'] = validateLength;
      if(Platform.OS == 'win32') {
        mCtrl.$validators['invalidAscii'] = validateAscii;
        mCtrl.$validators['invalidFormat'] = validateFormatWindows;
        mCtrl.$validators['invalidDisk'] = validateDisk;
      }
    }
  };
}

export default pathValidator;

{'fraction_non_alphanumeric': 0.16157501697216564, 'fraction_numerical': 0.00746775288526816, 'mean_word_length': 2.8223086900129704, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2345895', 'n_tokens_mistral': 941, 'n_tokens_neox': 896, 'n_words': 162}