lib/whyvalidationssuckin96/macros/validates_date.rb in whyvalidationssuckin96-1.5.1 vs lib/whyvalidationssuckin96/macros/validates_date.rb in whyvalidationssuckin96-1.5.2
- old
+ new
@@ -8,10 +8,12 @@
# @example Default usage
# setup_validations do
# validates_as_date :start_date
# end
class ValidatesDate < Validation
+ attr_reader :date
+
include WhyValidationsSuckIn96::SkippableValidation
include WhyValidationsSuckIn96::AttributeBasedValidation
DefaultDelimiters = %r{[-/]}
DefaultParser = lambda do |str|
month, day, year = str.split(DefaultDelimiters, 3)
@@ -43,10 +45,10 @@
private
def parse_date
parsed = options[:parser].call(attribute_value.to_s)
- Date.civil(parsed[:year].to_i, parsed[:month].to_i, parsed[:day].to_i)
+ @date = Date.civil(parsed[:year].to_i, parsed[:month].to_i, parsed[:day].to_i)
end
end # Validation
ValidationBuilder.register_macro :validates_as_date, WhyValidationsSuckIn96::ValidatesDate
end # WhyValidationsSuckIn96
\ No newline at end of file