3
4
5
6
7
8
9
|
# File 'app/validators/mds_birthdate_validator.rb', line 3
def validate_each(record, attribute, value)
return true if record.send("clean_#{attribute}").blank?
record.errors[attribute] << "Invalid birth date entered in #{attribute}. Birth date may contain only numbers." and return if value =~ /\D/
record.errors[attribute] << "Invalid birth date entered in #{attribute}. Birth date must be formatted as YYYYMMDD, YYYYMM or YYYY." and return unless birthdate_correct_length?(value)
record.errors[attribute] << "Invalid birth date entered in #{attribute}. Birth date is not valid." unless birthdate_ymd_valid?(value)
end
|