From c9f90fb8ced10b177125a094545cc6ed079a5fdc Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Wed, 7 Jul 2021 11:50:56 +0530 Subject: [PATCH] FIX: text length validation bug --- lib/custom_wizard/validators/update.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/custom_wizard/validators/update.rb b/lib/custom_wizard/validators/update.rb index 93d4955f..c722a763 100644 --- a/lib/custom_wizard/validators/update.rb +++ b/lib/custom_wizard/validators/update.rb @@ -32,11 +32,11 @@ class ::CustomWizard::UpdateValidator @updater.errors.add(field_id, I18n.t('wizard.field.required', label: label)) end - if min_length && value.is_a?(String) && value.strip.length < min_length.to_i + if min_length.present? && value.is_a?(String) && value.strip.length < min_length.to_i @updater.errors.add(field_id, I18n.t('wizard.field.too_short', label: label, min: min_length.to_i)) end - if max_length && value.is_a?(String) && value.strip.length > max_length.to_i + if max_length.present? && value.is_a?(String) && value.strip.length > max_length.to_i @updater.errors.add(field_id, I18n.t('wizard.field.too_long', label: label, max: max_length.to_i)) end