##// END OF EJS Templates
Workaround for #12750....
Jean-Philippe Lang -
r10908:b29d74f9d5df
parent child
Show More
@@ -43,7 +43,8 class DateValidator < ActiveModel::EachValidator
43 def validate_each(record, attribute, value)
43 def validate_each(record, attribute, value)
44 before_type_cast = record.attributes_before_type_cast[attribute.to_s]
44 before_type_cast = record.attributes_before_type_cast[attribute.to_s]
45 if before_type_cast.is_a?(String) && before_type_cast.present?
45 if before_type_cast.is_a?(String) && before_type_cast.present?
46 unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}\z/ && value
46 # TODO: #*_date_before_type_cast returns a Mysql::Time with ruby1.8+mysql gem
47 unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value
47 record.errors.add attribute, :not_a_date
48 record.errors.add attribute, :not_a_date
48 end
49 end
49 end
50 end
General Comments 0
You need to be logged in to leave comments. Login now