I currently have a function to check for the correct delivery:
validates :birth_year, presence: true, format: {with: /(19|20)\d{2}/i }
I also have a function that checks for the correct date:
validate :birth_year_format private def birth_year_format errors.add(:birth_year, "should be a four-digit year") unless (1900..Date.today.year).include?(birth_year.to_i) end
Is it possible to combine the lower method into validates from above, and not the two checks that I have now?
perseverance
source share