Rails validate three types of date format
===

i'm developing a Ruby on Rails application which uses a special kind of date format.
The date format in question is Year.month.day and a date can be:

Year.month.day
Year.month
Year

I'm working on a validation method that has to check the format and if the input date fits any of those formats, make it valid. So far my code is:

    def data_format_correct
    regexymd = /[0-9]{4}[.][0-9]{1,2}[.][0-9]{1,2}/
    regexym = /[0-9]{4}[.][0-9]{1,2}/
    regexy = /[0-9]{4}/
    if :data.to_s =~ regexymd
      return true
    elsif  :data.to_s =~ regexym
      return true
    elsif :data.to_s =~ regexy
      return true
    else
      errors.add(:data)
      return
    end
  end

Everytime i put a date in the form, the else case rises with the error. I'm pretty sure my code is correct. Am I missing something?