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
|
||||
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.messages.create(message_params)
|
||||
end
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user