How to use the vee-validate.Validator function in vee-validate

To help you get started, we’ve selected a few vee-validate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tencent / bk-cmdb / src / ui / src / views / business-topology / service-instance / instance / options.vue View on Github external
async handleCopy (disabled) {
                if (disabled) {
                    return false
                }
                try {
                    const validator = new Validator()
                    const validPromise = []
                    this.selection.forEach(row => {
                        const ip = row.name.split('_')[0]
                        validPromise.push(new Promise(async resolve => {
                            const { valid } = await validator.verify(ip, MULTIPLE_IP_REGEXP)
                            resolve({ valid, ip })
                        }))
                    })
                    const results = await Promise.all(validPromise)
                    const validResult = results.filter(result => result.valid).map(result => result.ip)
                    const unique = [...new Set(validResult)]
                    if (unique.length) {
                        await this.$copyText(unique.join('\n'))
                        this.$success(this.$t('复制成功'))
                    } else {
                        this.$warn(this.$t('暂无可复制的IP'))
github 14nrv / vue-form-json / src / components / Form / FormError.spec.js View on Github external
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import { slug } from '@/helpers'
import Form from '@/components/Form'

const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)

let wrapper, b
const FORM_NAME = 'testFormName'
const MIN_LENGTH = 10
const LABEL_INPUT = 'test input'
const INPUT_NUMBER = 'input[name=number]'
const INPUT_NUMBER_PROPS = {
  label: 'Number',
  type: 'number',
  min: 18,
  max: 99
}

describe('Form Error', () => {
github 14nrv / vue-form-json / src / components / Form / Form.spec.js View on Github external
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import flatten from 'ramda/src/flatten'
import pickAll from 'ramda/src/pickAll'
import map from 'ramda/src/map'
import { slug } from '@/helpers'
import Form from '@/components/Form'
import fields from './fields'

const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)
localVue.filter('slugify', str => slug(str))

let wrapper, b
const $inputSubmit = 'input[type=submit]'
const $reset = 'input[type=reset]'
const $inputFirstName = 'input[name=first-name]'
const $inputLastName = 'input[name=last-name]'
const $inputPassword = 'input[name=password]'
const $errorMessage = '.help.is-danger'
const $errorIcon = '.fa-exclamation-triangle'

const FORM_NAME = 'testFormName'
const DEFAULT_VALUE = 'test'
const EMAIL_VALUE = `${DEFAULT_VALUE}@aol.fr`
github logaretm / vee-validate / docs / src / js / components / examples / ValidatorExample.vue View on Github external
created() {
    this.validator = new Validator({
      email: 'required|email',
      name: 'required|alpha|min:3'
    });
    this.$set(this, 'errors', this.validator.errors);
  }
};
github 14nrv / vue-form-json / src / components / Form / FormAttr.spec.js View on Github external
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import Form from '@/components/Form'

const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)

let wrapper, b
const FORM_NAME = 'testFormName'

describe('custom css class', () => {
  beforeEach(() => {
    wrapper = mount(Form, {
      localVue,
      provide: () => ({ $validator: v }),
      propsData: {
        formFields: [{ label: 'default' }],
        formName: FORM_NAME
      }
    })
github 14nrv / vue-form-json / src / components / Form / FormHtml.spec.js View on Github external
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import Form from '@/components/Form'

const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)

let wrapper, b

const FORM_NAME = 'testFormName'
const htmlContainer = '[data-test=htmlContentFromFormFields]'

describe('Form with html content inside json', () => {
  beforeEach(() => {
    wrapper = mount(Form, {
      localVue,
      provide: () => ({ $validator: v }),
      propsData: {
        formFields: [{ label: 'defaultLabel' }],
        formName: FORM_NAME