I see there has been lots of chatter over the years on how to properly
validate the presence of a boolean field.
The community has settled, rightly, on this
validates :field, inclusion: { in: [true, false] }
# or
validates :field, exclusion: { in: [nil] }
I'd like to suggest that we make this even better and add a `boolean`
validator to allow for:
validates :field, boolean: true
By using this method we would not only validate presence, but also the
inclusion of a `true` or `false` value.
Would love to hear thoughts on this. PR incoming.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-core/3aa918ec-d337-4b96-be4b-cbab60a4aeec%40googlegroups.com.