Dynamic validation schema not updating when optionMergeStrategy defined
See original GitHub issueHi, I have a mixin where I load validation rules from my backend and assign them to the data property in the created hook. This works as expected. Now I want to expand these validation rules in my components at will. I wrote a customMergeStrategy to merge the two validation rules, but it seems like this disables the behavior of the validations () function, because it does not jump into it when I do the following in created:
this.validationRules = {
required,
minLength: minLength(5)
}
I expected it to jump in the validations() function and to return the correct validation rules:
return { text: this.validationRules }
Am I missing a point or is this a bug?
Here is a fiddle which shows my problem (without the mixin and with the customMergeStrategy doing nothing but returning the validation object to keep things as simple as possible): https://jsfiddle.net/LarsRip/hy0joanc/8/
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Found the solution: You can simply use the merge strategy from data:
Vue.config.optionMergeStrategies.validations = Vue.config.optionMergeStrategies.data
Working fiddle: https://jsfiddle.net/zw6d5bp9/
@kosanr1 when you define rules on backend what kind of data format are you using: example