fix: Add validations dynamically for pre-chat form (#1779)

This commit is contained in:
Pranav Raj S 2021-02-16 15:15:37 +05:30 committed by GitHub
parent 1706199a0e
commit ec557205f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View file

@ -71,18 +71,30 @@ export default {
default: () => ({}),
},
},
validations: {
fullName: {
required,
},
emailAddress: {
required,
email,
},
message: {
required,
minLength: minLength(10),
},
validations() {
const identityValidations = {
fullName: {
required,
},
emailAddress: {
required,
email,
},
};
const messageValidation = {
message: {
required,
minLength: minLength(10),
},
};
if (this.options.requireEmail) {
return {
...identityValidations,
...messageValidation,
};
}
return messageValidation;
},
data() {
return {