<commit_before>import React, { useCallback, useContext, useState } from 'react';
import { Form, FormRenderProps } from 'react-final-form';
import { ArrowLeftIcon } from '@primer/octicons-react';
import { useHistory } from 'react-router-dom';
import { shell } from 'electron';

import { AppContext } from '../context/App';
import { AuthTokenOptions } from '../types';
import { Constants } from '../utils/constants';
import { FieldInput } from '../components/fields/FieldInput';

interface IValues {
  token?: string;
  hostname?: string;
}

interface IFormErrors {
  token?: string;
  hostname?: string;
}

export const validate = (values: IValues): IFormErrors => {
  const errors: IFormErrors = {};
  if (!values.token) {
    errors.token = 'Required';
  } else if (!/^[A-Z0-9]{40}$/i.test(values.token)) {
    errors.token = 'Invalid token.';<commit_msg>Accept underscore characters in personal access tokens (#492)<commit_after>import React, { useCallback, useContext, useState } from 'react';
import { Form, FormRenderProps } from 'react-final-form';
import { ArrowLeftIcon } from '@primer/octicons-react';
import { useHistory } from 'react-router-dom';
import { shell } from 'electron';

import { AppContext } from '../context/App';
import { AuthTokenOptions } from '../types';
import { Constants } from '../utils/constants';
import { FieldInput } from '../components/fields/FieldInput';

interface IValues {
  token?: string;
  hostname?: string;
}

interface IFormErrors {
  token?: string;
  hostname?: string;
}

export const validate = (values: IValues): IFormErrors => {
  const errors: IFormErrors = {};
  if (!values.token) {
    errors.token = 'Required';
  } else if (!/^[A-Z0-9_]{40}$/i.test(values.token)) {
    errors.token = 'Invalid token.';
{'fraction_non_alphanumeric': 0.15956842703009655, 'fraction_numerical': 0.006246450880181715, 'mean_word_length': 4.371951219512195, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5691845', 'n_tokens_mistral': 541, 'n_tokens_neox': 531, 'n_words': 148}