Skip to content

Commit 870bd62

Browse files
committed
fix: uniqueness validator _does_ allow nil
1 parent b88bad7 commit 870bd62

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/anchor/resource.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ def anchor_attributes_properties(included_fields:)
7878
description ||= column.comment if Anchor.config.use_active_record_comment
7979
check_presence = type.is_a?(Anchor::Types::Maybe) && Anchor.config.use_active_record_presence
8080
if check_presence && _model_class.validators_on(model_method).any? do |v|
81-
if v.is_a?(ActiveRecord::Validations::UniquenessValidator)
82-
opts = v.options.with_indifferent_access
83-
!(opts[:allow_nil] || opts[:allow_blank] || opts[:if] || opts[:unless] || opts[:on])
84-
elsif v.is_a?(ActiveRecord::Validations::NumericalityValidator)
81+
if v.is_a?(ActiveRecord::Validations::NumericalityValidator)
8582
opts = v.options.with_indifferent_access
8683
!(opts[:allow_nil] || opts[:if] || opts[:unless] || opts[:on])
8784
elsif v.is_a?(ActiveRecord::Validations::PresenceValidator)

0 commit comments

Comments
 (0)