'Vue js vuelidate cannot create Dynamic validation schema
I need t o create Dynamic validation schema with many checks, because date could have different parameters.
i tried to do something like this
validations() {
if (this.NewItem.type === 3) {
return {
NewItem: {
abp: { required },
bp: {},
ppr: { },
name_ru: {required},
}
};
}
else if (this.NewItem.type === 4)
{
return {
NewItem: {
abp: {},
bp: {required},
ppr: { },
name_ru: { required }
}
};}
else if (this.NewItem.type === 5)
{
return {
NewItem: {
abp: {},
bp: { },
ppr: { required },
name_ru: { required }
}
};}
},
it's not working.
**Only works this way **
validations() {
if (!this.hasDescription) {
return {
name: {
required
}
}
} else {
return {
name: {
required
},
description: {
required
}
}
}
}
}
but i need more more options
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
