first off, thanks for the gem! very handy!
so, to be honest, i'm not 100% convinced this is really a bug, but figured i'd raise it, just in case it is. please excuse me if this has been discussed previously -- i was unable to find any mention of it in issues.
so -- if you have a non-null integer field that has a validation like:
validates :rank, numericality: {greater_than_or_equal_to: 0}, allow_nil: false
then it is my belief that this should suffice as a presence validator even though presence: true is not explicitly listed in the validator. one could include this but it is redundant, imho, based on the following (from https://guides.rubyonrails.org/active_record_validations.html#numericality)
By default, numericality doesn't allow nil values. You can use allow_nil: true option to permit it. For Integer and Float columns empty strings are converted to nil.
so in the example above allow_nil: false should not really even be necessary as it is the default. so the existence of the numericality: validator -- in the absence of allow_nil: true should suffice to be a presence validator for non-null integer columns, yes?
if my assertion is correct, i'd consider adding a PR to address this, once i get my fingers into the code. i welcome discussion. thanks for reading!
first off, thanks for the gem! very handy!
so, to be honest, i'm not 100% convinced this is really a bug, but figured i'd raise it, just in case it is. please excuse me if this has been discussed previously -- i was unable to find any mention of it in issues.
so -- if you have a non-null integer field that has a validation like:
then it is my belief that this should suffice as a presence validator even though
presence: trueis not explicitly listed in the validator. one could include this but it is redundant, imho, based on the following (from https://guides.rubyonrails.org/active_record_validations.html#numericality)so in the example above
allow_nil: falseshould not really even be necessary as it is the default. so the existence of thenumericality:validator -- in the absence ofallow_nil: trueshould suffice to be a presence validator for non-null integer columns, yes?if my assertion is correct, i'd consider adding a PR to address this, once i get my fingers into the code. i welcome discussion. thanks for reading!