Created
April 7, 2009 23:05
-
-
Save davidphasson/91528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Time specifications: | |
validates_each :assembly_time2 do |record, attr, value| | |
next if value.nil? | |
# Leave this up to other validation | |
next if record.assembly_time1.nil? | |
if value < ( record.assembly_time1 + 1.hour + 15.minutes ) | |
record.errors.add attr, "must allow for at least one hour assembly and 15 minute break" | |
end | |
end | |
validates_each :assembly_time3 do |record, attr, value| | |
next if value.nil? | |
# Leave this up to other validation | |
next if record.assembly_time2.nil? | |
if value < ( record.assembly_time2 + 1.hour + 15.minutes ) | |
record.errors.add attr, "must allow for at least one hour assembly and 15 minute break" | |
end | |
end | |
validates_each :assembly_time1 do |record, attr, value| | |
next if value.nil? | |
# Must be later than 9:30 | |
if (value.hour < 9) || (value.hour == 9 && value.min < 30 ) | |
record.errors.add attr, "must be no earlier than 9:30am" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment