Class: Cl::Opts::Validate::Requireds

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:



41
42
43
# File 'lib/cl/opts/validate.rb', line 41

def apply
  raise RequiredsOpts.new(missing) if missing.any?
end

#missingObject



45
46
47
48
49
# File 'lib/cl/opts/validate.rb', line 45

def missing
  @missing ||= cmd.class.required.map do |alts|
    alts if alts.none? { |alt| Array(alt).all? { |key| values.key?(key) } }
  end.compact
end