Sha256: b53a34367ddbed58cc299bd0525688e85b900cb61a448650db802881d3573c26

Contents?: true

Size: 417 Bytes

Versions: 1

Compression:

Stored size: 417 Bytes

Contents

module CLIUtils
  # A Validator to verify whether a Pref answer
  # is a valid time.
  class TimeValidator < PrefValidator
    # Runs the Validator against the answer.
    # @param [Object] text The "text" to evaluate
    # @return [String]
    def validate(text)
      @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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliutils-2.1.3 lib/cliutils/prefs/pref_validators/time_validator.rb