vee-validate icon indicating copy to clipboard operation
vee-validate copied to clipboard

[v4] Question: How to get target cross field name ?

Open devCodeHub-star opened this issue 1 year ago • 3 comments

Hello @logaretm I am upgraded to v4 and I have this use case

import { defineRule } from 'vee-validate'
import { isEqual } from 'lodash'

defineRule('isDifferent', (value, { target }, ctx) => {
  if (isEqual(target, value)) {
    return `The ${ctx.field} must be different from ?`
  }
  return true
})

How I can get access of target field name without defining it manually ? In v3 I am able to get access by message function like below code

message(field, values) {
   return i18n.t('error.notSame', values)
 }, 

And i18n message was The {_field_} must be different from {target}

Thanks

devCodeHub-star avatar Nov 10 '23 10:11 devCodeHub-star

I would like to know this as well!

It seems that this feature has disappeared after Vue 3 :(

HeuHax avatar Jan 09 '24 05:01 HeuHax

Hello, any news ? Did you find a solution ?

Falcomfr avatar Apr 02 '24 12:04 Falcomfr

@logaretm

Falcomfr avatar May 06 '24 14:05 Falcomfr