From 620f30368e1ed1d4b79d0353dbee7a5ac2efb2a7 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 11 Jun 2019 17:19:46 +1000 Subject: [PATCH] bugfix min length --- lib/builder.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/builder.rb b/lib/builder.rb index 10c76810..13434d28 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -227,7 +227,11 @@ class CustomWizard::Builder def validate_field(field, updater, step_template) value = updater.fields[field['id']] - min_length = field['min_length'] + min_length = false + + if is_text_type(field) + min_length = field['min_length'] + end if min_length && value.is_a?(String) && value.strip.length < min_length.to_i label = field['label'] || I18n.t("#{field['key']}.label") @@ -246,6 +250,10 @@ class CustomWizard::Builder end end + def is_text_type(field) + ['text', 'textarea'].include? field['type'] + end + def standardise_boolean(value) !!HasCustomFields::Helpers::CUSTOM_FIELD_TRUE.include?(value) end