- Short Ruby Newsletter
- Posts
- Rails 7.1 validate with endless and beginless range
Rails 7.1 validate with endless and beginless range
#code #summary #rails71 #validation #validators
This is a summary of the article, and some of the code lines are taken from there:
Code:
# endless range exampleclass Person validates_length_of :first_name, in: 20..end# endless range exampleclass User validates_length_of :first_name, within: 20..end# endless and beginless range exampleclass Food validates :created_at, inclusion: { in: proc { (..Date.today) } } validates :expired_at, inclusion: { in: proc { (Date.today..) } }end
Reply