<commit_before>const validSqlRegex = /^[a-z0-9_]+$/,
      entypeRegex = /^[a-z0-9_]{1,20}$/,
      evnameRegex = /^(@set|[a-z0-9_]{1,40})$/,
      isoRegex = /(\d{4})-(\d{2})-(\d{2})T((\d{2}):(\d{2}):(\d{2}))\.(\d{3})Z/,
      reservedWords = new Set(require('./reserved-words'))

function validateEvent(opts, event) {
  var errors = []

  if (event[event.entype === 'user' ? 'user_id' : 'enid'] == null) {
    errors.push('you must specify user_id if entype is `user`, otherwise you must specify the `enid`')
  }
  if (event.user_id != null && (typeof event.user_id !== 'string' || event.user_id.length > 40 || !event.user_id.length)) {
    errors.push('user_id must be a string less than 40 characters long')
  }
  if (!entypeRegex.test(event.entype)) {
    errors.push('entype does not match ' + entypeRegex.toString())
  }
  if (!evnameRegex.test(event.evname)) {
    errors.push('evname does not match ' + evnameRegex.toString())
  }
  if (event.ts != null && !isoRegex.test(event.ts)) {
    errors.push('ts is not a valid ISO timestamp')
  }
  if (event.body != null) {
    if (typeof event.body !== 'object') {
      errors.push('body must be an object')
    } else {
      for (var k in event.body) {
        if (!validSqlRegex.test(k)) {
          errors.push(`Body key ${k} does not match ${validSqlRegex.toString()}`)
        }
        if (reservedWords.has(k.toUpperCase())) {
          if (opts.transformReservedWordKeys) {
            event.body[k + '_'] = event.body[k]
            delete event.body[k]
          } else {
            errors.push(`Body key ${k} is a reserved SQL keyword`)
          }
        }
      }
    }
  }<commit_msg>check enid length is less than 40<commit_after>const validSqlRegex = /^[a-z0-9_]+$/,
      entypeRegex = /^[a-z0-9_]{1,20}$/,
      evnameRegex = /^(@set|[a-z0-9_]{1,40})$/,
      isoRegex = /(\d{4})-(\d{2})-(\d{2})T((\d{2}):(\d{2}):(\d{2}))\.(\d{3})Z/,
      reservedWords = new Set(require('./reserved-words'))

function validateEvent(opts, event) {
  var errors = []

  if (event[event.entype === 'user' ? 'user_id' : 'enid'] == null) {
    errors.push('you must specify user_id if entype is `user`, otherwise you must specify the `enid`')
  }
  if (event.user_id != null && (typeof event.user_id !== 'string' || event.user_id.length > 40 || !event.user_id.length)) {
    errors.push('user_id must be a string less than 40 characters long')
  }
  if (event.enid != null && (typeof event.enid !== 'string' || event.enid.length > 40 || !event.enid.length)) {
    errors.push('enid must be a string less than 40 characters long')
  }
  if (!entypeRegex.test(event.entype)) {
    errors.push('entype does not match ' + entypeRegex.toString())
  }
  if (!evnameRegex.test(event.evname)) {
    errors.push('evname does not match ' + evnameRegex.toString())
  }
  if (event.ts != null && !isoRegex.test(event.ts)) {
    errors.push('ts is not a valid ISO timestamp')
  }
  if (event.body != null) {
    if (typeof event.body !== 'object') {
      errors.push('body must be an object')
    } else {
      for (var k in event.body) {
        if (!validSqlRegex.test(k)) {
          errors.push(`Body key ${k} does not match ${validSqlRegex.toString()}`)
        }
        if (reservedWords.has(k.toUpperCase())) {
          if (opts.transformReservedWordKeys) {
            event.body[k + '_'] = event.body[k]
            delete event.body[k]
          } else {
            errors.push(`Body key ${k} is a reserved SQL keyword`)
          }
        }
      }
    }
  }
{'fraction_non_alphanumeric': 0.1876065946560546, 'fraction_numerical': 0.014781125639567936, 'mean_word_length': 2.6925498426023085, 'pattern_counts': {'":': 0, '<': 3, '<?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': '611732', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1217, 'n_words': 275}