Improved error messages for type attributes.

This commit is contained in:
Martin Edenhofer 2018-05-14 11:09:23 +02:00
parent 91bdf9f814
commit cabb1c89d1

View file

@ -769,8 +769,8 @@ to send no browser reload event, pass false
# validate data_option # validate data_option
if data_type == 'input' if data_type == 'input'
raise 'Need data_option[:type] param' if !data_option[:type] raise 'Need data_option[:type] param e. g. (text|password|tel|fax|email|url)' if !data_option[:type]
raise "Invalid data_option[:type] param '#{data_option[:type]}'" if data_option[:type] !~ /^(text|password|tel|fax|email|url)$/ raise "Invalid data_option[:type] param '#{data_option[:type]}' (text|password|tel|fax|email|url)" if data_option[:type] !~ /^(text|password|tel|fax|email|url)$/
raise 'Need data_option[:maxlength] param' if !data_option[:maxlength] raise 'Need data_option[:maxlength] param' if !data_option[:maxlength]
raise "Invalid data_option[:maxlength] param #{data_option[:maxlength]}" if data_option[:maxlength].to_s !~ /^\d+?$/ raise "Invalid data_option[:maxlength] param #{data_option[:maxlength]}" if data_option[:maxlength].to_s !~ /^\d+?$/
end end