fix: Add validations dynamically for pre-chat form (#1779)
This commit is contained in:
@@ -7,7 +7,7 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
update_contact(contact_email) if @contact.email.blank?
|
update_contact(contact_email) if @contact.email.blank? && contact_email.present?
|
||||||
@conversation = create_conversation
|
@conversation = create_conversation
|
||||||
conversation.messages.create(message_params)
|
conversation.messages.create(message_params)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ export default {
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
validations: {
|
validations() {
|
||||||
|
const identityValidations = {
|
||||||
fullName: {
|
fullName: {
|
||||||
required,
|
required,
|
||||||
},
|
},
|
||||||
@@ -79,10 +80,21 @@ export default {
|
|||||||
required,
|
required,
|
||||||
email,
|
email,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const messageValidation = {
|
||||||
message: {
|
message: {
|
||||||
required,
|
required,
|
||||||
minLength: minLength(10),
|
minLength: minLength(10),
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
if (this.options.requireEmail) {
|
||||||
|
return {
|
||||||
|
...identityValidations,
|
||||||
|
...messageValidation,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return messageValidation;
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user