diff --git a/app/models/object_manager/attribute/validation/required.rb b/app/models/object_manager/attribute/validation/required.rb index 66ea91bc9..1bc6847ae 100644 --- a/app/models/object_manager/attribute/validation/required.rb +++ b/app/models/object_manager/attribute/validation/required.rb @@ -3,7 +3,7 @@ class ObjectManager::Attribute::Validation::Required < ObjectManager::Attribute::Validation::Backend def validate - return if value.present? + return if !value.nil? return if optional_for_user? invalid_because_attribute('is required but missing.') diff --git a/spec/models/object_manager/attribute/validation/required_spec.rb b/spec/models/object_manager/attribute/validation/required_spec.rb index 84f6adf89..3d8e29416 100644 --- a/spec/models/object_manager/attribute/validation/required_spec.rb +++ b/spec/models/object_manager/attribute/validation/required_spec.rb @@ -41,6 +41,14 @@ RSpec.describe ::ObjectManager::Attribute::Validation::Required do } end + context 'when boolean field with false values' do + let(:value) { false } + let(:attribute) { build(:object_manager_attribute_boolean) } + let(:action) { 'create_middle' } + + it_behaves_like 'a validation without errors' + end + context 'when action is edit' do let(:action) { 'edit' }