mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
use the value from validates_each in validator
This commit is contained in:
parent
a1ae5f9313
commit
7ef9078369
@ -55,7 +55,7 @@ module ValidatesTimeliness
|
|||||||
configuration.delete(:allow_nil)
|
configuration.delete(:allow_nil)
|
||||||
configuration.delete(:allow_blank)
|
configuration.delete(:allow_blank)
|
||||||
validates_each(attr_names, configuration) do |record, attr_name, value|
|
validates_each(attr_names, configuration) do |record, attr_name, value|
|
||||||
validator.call(record, attr_name)
|
validator.call(record, attr_name, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -32,8 +32,7 @@ module ValidatesTimeliness
|
|||||||
validate_options(@configuration)
|
validate_options(@configuration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(record, attr_name)
|
def call(record, attr_name, value)
|
||||||
value = record.send(attr_name)
|
|
||||||
value = record.class.parse_date_time(value, type, false) if value.is_a?(String)
|
value = record.class.parse_date_time(value, type, false) if value.is_a?(String)
|
||||||
raw_value = raw_value(record, attr_name)
|
raw_value = raw_value(record, attr_name)
|
||||||
|
|
||||||
|
|||||||
@ -500,7 +500,7 @@ describe ValidatesTimeliness::Validator do
|
|||||||
|
|
||||||
def validate_with(attr_name, value)
|
def validate_with(attr_name, value)
|
||||||
person.send("#{attr_name}=", value)
|
person.send("#{attr_name}=", value)
|
||||||
validator.call(person, attr_name)
|
validator.call(person, attr_name, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_have_error(attr_name, error)
|
def should_have_error(attr_name, error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user