You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly, the one for conditional validations could be achieved with allow_nil and allow_blank:
classUser < ActiveRecord::Base# If the user provided a username, it must be at least 8 charactersvalidates:username,length: {minimum: 8},allow_nil: true,allow_blank: trueend
The text was updated successfully, but these errors were encountered:
Sure we could use a more complicated example to show a custom validation
and we could do my custom validation with the built-in tools, but the point
is simply to show how a custom validation can be written and used without
having to learn another algorithm as well, for the initial example.
Luhn makes a very good use-case for a followup example or homework however.
The custom method one can be validated with
inclusion
:Similarly, the one for conditional validations could be achieved with
allow_nil
andallow_blank
:The text was updated successfully, but these errors were encountered: