mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
add validator type accessor
This commit is contained in:
parent
7117a5ef22
commit
b22a7c41b8
@ -4,6 +4,8 @@ module ValidatesTimeliness
|
|||||||
class Validator < ActiveModel::EachValidator
|
class Validator < ActiveModel::EachValidator
|
||||||
include Conversion
|
include Conversion
|
||||||
|
|
||||||
|
attr_reader :type
|
||||||
|
|
||||||
RESTRICTIONS = {
|
RESTRICTIONS = {
|
||||||
:is_at => :==,
|
:is_at => :==,
|
||||||
:before => :<,
|
:before => :<,
|
||||||
|
|||||||
@ -22,7 +22,7 @@ describe ValidatesTimeliness::Validator do
|
|||||||
|
|
||||||
it 'should use default to :datetime type' do
|
it 'should use default to :datetime type' do
|
||||||
Person.validates :birth_datetime, :timeliness => {:is_at => Time.mktime(2010,1,1)}
|
Person.validates :birth_datetime, :timeliness => {:is_at => Time.mktime(2010,1,1)}
|
||||||
Person.validators.first.instance_variable_get(:@type).should == :datetime
|
Person.validators.first.type.should == :datetime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user