[Vuejs]-Set a rule depending on a data prop on a vueJS form input

0👍

Yes, it’s possible. The mistakes that you were making

  • rules should be a computed property, since it can change
  • you should call it with parent component and pass prop maxLength

Here’s a working example for you, where Validation is the component implementing rules and App is the parent component calling it with prop maxLength: https://codesandbox.io/s/nostalgic-thunder-mvl6o.

Leave a comment