feat: Add regex validation on form message inputs (#2317)
Co-authored-by: Nithin David Thomas <webofnithin@gmail.com> Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -74,18 +74,25 @@ module WootMessageSeeder
|
||||
message_type: :template,
|
||||
content_type: 'form',
|
||||
content: 'form',
|
||||
content_attributes: {
|
||||
items: [
|
||||
{ name: 'email', placeholder: 'Please enter your email', type: 'email', label: 'Email' },
|
||||
{ name: 'text_area', placeholder: 'Please enter text', type: 'text_area', label: 'Large Text' },
|
||||
{ name: 'text', placeholder: 'Please enter text', type: 'text', label: 'text', default: 'defaut value' },
|
||||
{ name: 'select', label: 'Select Option', type: 'select', options: [{ label: '🌯 Burito', value: 'Burito' },
|
||||
{ label: '🍝 Pasta', value: 'Pasta' }] }
|
||||
]
|
||||
}
|
||||
content_attributes: sample_form
|
||||
)
|
||||
end
|
||||
|
||||
def self.sample_form
|
||||
{
|
||||
"items": [
|
||||
{ "name": 'email', "placeholder": 'Please enter your email', "type": 'email', "label": 'Email', "required": 'required',
|
||||
"pattern_error": 'Please fill this field', "pattern": '^[^\s@]+@[^\s@]+\.[^\s@]+$' },
|
||||
{ "name": 'text_area', "placeholder": 'Please enter text', "type": 'text_area', "label": 'Large Text', "required": 'required',
|
||||
"pattern_error": 'Please fill this field' },
|
||||
{ "name": 'text', "placeholder": 'Please enter text', "type": 'text', "label": 'text', "default": 'defaut value', "required": 'required',
|
||||
"pattern": '^[a-zA-Z ]*$', "pattern_error": 'Only alphabets are allowed' },
|
||||
{ "name": 'select', "label": 'Select Option', "type": 'select', "options": [{ "label": '🌯 Burito', "value": 'Burito' },
|
||||
{ "label": '🍝 Pasta', "value": 'Pasta' }] }
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
def self.create_sample_articles_message(conversation)
|
||||
Message.create!(
|
||||
account: conversation.account,
|
||||
|
||||
Reference in New Issue
Block a user