Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateEach and dynamic minValue #1215

Open
gimler opened this issue Nov 8, 2023 · 1 comment
Open

ValidateEach and dynamic minValue #1215

gimler opened this issue Nov 8, 2023 · 1 comment

Comments

@gimler
Copy link

gimler commented Nov 8, 2023

Is your feature request related to a problem? Please describe.
I use a ValidateEach component so i did no have access to the current item.
I need to calculate the minValue based on another field.

Describe the solution you'd like
I can override the validator this works.
The problem is the message. I need a way to set also the param min dynamicly

const vali = validatorMinValue(5.0)
vali.$validator = (value, vm) => value >= (vm.otherField * 2)
vali.$params ???
@gimler
Copy link
Author

gimler commented Nov 8, 2023

it works. but it feels hacky. is there a better solution?

const validatorMinValueFirstField = validatorMinValue(0)
validatorMinValueFirstField.$validator = function (value, vm) {
  this.rules.firstField.minValue.$params.min = vm.otherField * 2
  return value >= (vm.otherField * 2)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant