lib/cliutils/prefs/pref_validators/time_validator.rb in cliutils-2.1.2 vs lib/cliutils/prefs/pref_validators/time_validator.rb in cliutils-2.1.3
- old
+ new
@@ -4,10 +4,10 @@
class TimeValidator < PrefValidator
# Runs the Validator against the answer.
# @param [Object] text The "text" to evaluate
# @return [String]
def validate(text)
- @is_valid = !(Time.parse(text) rescue nil).nil?
+ @is_valid = text.to_s =~ /^([01]?[0-9]|2[0-3])\:[0-5][0-9](\s?[AaPp][Mm])?$/
@message = "Response is not a time: #{ text }"
end
end
end
\ No newline at end of file