use I18n default value when missing value for error value format

This commit is contained in:
Adam Meehan
2010-09-27 15:07:57 +10:00
parent cd62163152
commit ea082b5258
2 changed files with 22 additions and 1 deletions

View File

@@ -14,6 +14,12 @@ module ValidatesTimeliness
:on_or_after => :>=,
}.freeze
DEFAULT_ERROR_VALUE_FORMATS = {
:date => '%Y-%m-%d',
:time => '%H:%M:%S',
:datetime => '%Y-%m-%d %H:%M:%S'
}.freeze
def self.kind
:timeliness
end
@@ -56,7 +62,7 @@ module ValidatesTimeliness
end
def format_error_value(value)
format = I18n.t(@type, :scope => 'validates_timeliness.error_value_formats')
format = I18n.t(@type, :default => DEFAULT_ERROR_VALUE_FORMATS[@type], :scope => 'validates_timeliness.error_value_formats')
value.strftime(format)
end