<commit_before>import { PRIORITY_VALIDATE, REGEX_FILTER } from '../const'
import { warn, each } from '../util'


export default function (Vue) {
  const vIf = Vue.directive('if')
  const FragmentFactory = Vue.FragmentFactory
  const parseDirective = Vue.parsers.directive.parseDirective
  const {
    inBrowser, bind, on, off, createAnchor,
    replace, camelize, isPlainObject
  } = Vue.util

  // Test for IE10/11 textarea placeholder clone bug
  function checkTextareaCloneBug () {
    if (inBrowser) {
      let t = document.createElement('textarea')
      t.placeholder = 't'
      return t.cloneNode(true).value === 't'
    } else {
      return false
    }
  }
  const hasTextareaCloneBug = checkTextareaCloneBug()


  /**
   * `v-validate` directive
   */

  Vue.directive('validate', {
    terminal: true,
    priority: vIf.priority + PRIORITY_VALIDATE,
    params: ['group', 'field', 'detect-blur', 'detect-change', 'initial', 'classes'],

    paramWatchers: {
      detectBlur (val, old) {
        if (this._invalid) { return }
        this.validation.detectBlur = this.isDetectBlur(val) 
        this.validator.validate(this.field)
      },

      detectChange (val, old) {
        if (this._invalid) { return }
        this.validation.detectChange = this.isDetectChange(val)
        this.validator.validate(this.field)
      }
    },

    bind () {
      const el = this.el

      if ((process.env.NODE_ENV !== 'production') && el.__vue__) {
        warn('v-validate="' + this.expression + '" cannot be '
          + 'used on an instance root element.')
        this._invalid = true
        return
      }

      if ((process.env.NODE_ENV !== 'production') 
          && (el.hasAttribute('v-if') || el.hasAttribute('v-for'))) {
        warn('v-validate cannot be used `v-if` or `v-for` build-in terminal directive '
          + 'on an element. these is wrapped with `<template>` or other tags: '
          + '(e.g. <validator name="validator">'
          + '<template v-if="hidden">'
          + '<input type="text" v-validate:field1="[\'required\']">'
          + '</template>'
          + '</validator>).')
        this._invalid = true
        return
      }

      let validatorName = this.vm.$options._validator
      if ((process.env.NODE_ENV !== 'production') && !validatorName) {
        warn('v-validate need to use into validator element directive: '
          + '(e.g. <validator name="validator">'
          + '<input type="text" v-validate:field1="[\'required\']">'
          + '</validator>).')
        this._invalid = true
        return
      }<commit_msg>fix(v-validate): friendly error for field name missing (#205) by @xjchengo<commit_after>import { PRIORITY_VALIDATE, REGEX_FILTER } from '../const'
import { warn, each } from '../util'


export default function (Vue) {
  const vIf = Vue.directive('if')
  const FragmentFactory = Vue.FragmentFactory
  const parseDirective = Vue.parsers.directive.parseDirective
  const {
    inBrowser, bind, on, off, createAnchor,
    replace, camelize, isPlainObject
  } = Vue.util

  // Test for IE10/11 textarea placeholder clone bug
  function checkTextareaCloneBug () {
    if (inBrowser) {
      let t = document.createElement('textarea')
      t.placeholder = 't'
      return t.cloneNode(true).value === 't'
    } else {
      return false
    }
  }
  const hasTextareaCloneBug = checkTextareaCloneBug()


  /**
   * `v-validate` directive
   */

  Vue.directive('validate', {
    terminal: true,
    priority: vIf.priority + PRIORITY_VALIDATE,
    params: ['group', 'field', 'detect-blur', 'detect-change', 'initial', 'classes'],

    paramWatchers: {
      detectBlur (val, old) {
        if (this._invalid) { return }
        this.validation.detectBlur = this.isDetectBlur(val) 
        this.validator.validate(this.field)
      },

      detectChange (val, old) {
        if (this._invalid) { return }
        this.validation.detectChange = this.isDetectChange(val)
        this.validator.validate(this.field)
      }
    },

    bind () {
      const el = this.el

      if ((process.env.NODE_ENV !== 'production') && el.__vue__) {
        warn('v-validate="' + this.expression + '" cannot be '
          + 'used on an instance root element.')
        this._invalid = true
        return
      }

      if ((process.env.NODE_ENV !== 'production') 
          && (el.hasAttribute('v-if') || el.hasAttribute('v-for'))) {
        warn('v-validate cannot be used `v-if` or `v-for` build-in terminal directive '
          + 'on an element. these is wrapped with `<template>` or other tags: '
          + '(e.g. <validator name="validator">'
          + '<template v-if="hidden">'
          + '<input type="text" v-validate:field1="[\'required\']">'
          + '</template>'
          + '</validator>).')
        this._invalid = true
        return
      }

      if ((process.env.NODE_ENV !== 'production')
          && !(this.arg || this.params.field)) {
        warn('you need specify field name for v-validate directive.')
        this._invalid = true
        return
      }

      let validatorName = this.vm.$options._validator
      if ((process.env.NODE_ENV !== 'production') && !validatorName) {
        warn('v-validate need to use into validator element directive: '
          + '(e.g. <validator name="validator">'
          + '<input type="text" v-validate:field1="[\'required\']">'
          + '</validator>).')
        this._invalid = true
        return
      }
{'fraction_non_alphanumeric': 0.14841313520454963, 'fraction_numerical': 0.00275178866263071, 'mean_word_length': 2.441919191919192, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4771887', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1645, 'n_words': 383}