How to use the vuelidate/lib/validators/common.withParams function in vuelidate

To help you get started, we’ve selected a few vuelidate 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 gardener / dashboard / frontend / src / utils / validators.js View on Github external
}
const noStartEndHyphen = (value) => {
  return !startEndHyphenPattern.test(value)
}
const numberOrPercentage = (value) => {
  return numberOrPercentagePattern.test(value)
}

const unique = key => withParams({ type: 'unique', key },
  function (value, parentVm) {
    const keys = ref(key, this, parentVm)
    return !includes(keys, value)
  }
)

const uniqueWorkerName = withParams({ type: 'uniqueWorkerName' },
  function unique (value) {
    return this.workers.filter(item => item.name === value).length === 1
  }
)

const serviceAccountKey = withParams({ type: 'serviceAccountKey' },
  function (value) {
    try {
      const key = JSON.parse(value)
      if (key.project_id && alphaNumUnderscoreHyphen(key.project_id)) {
        return true
      }
    } catch (err) { /* ignore error */ }
    return false
  }
)
github gardener / dashboard / frontend / src / utils / validators.js View on Github external
}

const unique = key => withParams({ type: 'unique', key },
  function (value, parentVm) {
    const keys = ref(key, this, parentVm)
    return !includes(keys, value)
  }
)

const uniqueWorkerName = withParams({ type: 'uniqueWorkerName' },
  function unique (value) {
    return this.workers.filter(item => item.name === value).length === 1
  }
)

const serviceAccountKey = withParams({ type: 'serviceAccountKey' },
  function (value) {
    try {
      const key = JSON.parse(value)
      if (key.project_id && alphaNumUnderscoreHyphen(key.project_id)) {
        return true
      }
    } catch (err) { /* ignore error */ }
    return false
  }
)

const minVolumeSize = key => withParams({ type: 'minVolumeSize', key },
  function (value) {
    if (this.volumeInCloudProfile) {
      return minValue(key)(parseSize(value))
    }