Class: Cl::Opts::Validate::Format

Inherits:
Validator
  • Object
show all
Defined in:
lib/cl/opts/validate.rb

Instance Attribute Summary

Attributes inherited from Validator

#cmd, #opts, #orig, #values

Instance Method Summary collapse

Methods inherited from Validator

#compact, #invert, #only

Methods included from Regex

#format_regex

Instance Method Details

#applyObject

Raises:



70
71
72
# File 'lib/cl/opts/validate.rb', line 70

def apply
  raise InvalidFormat.new(invalid) if invalid.any?
end

#invalidObject



74
75
76
77
78
79
# File 'lib/cl/opts/validate.rb', line 74

def invalid
  @invalid ||= opts.select(&:format?).map do |opt|
    value = values[opt.name]
    [opt.name, opt.format] if value && !opt.formatted?(value)
  end.compact
end