lib/cl/opts/validate.rb in cl-1.0.1 vs lib/cl/opts/validate.rb in cl-1.0.2
- old
+ new
@@ -1,19 +1,19 @@
require 'cl/helper'
class Cl
class Opts
module Validate
- def validate(cmd, opts, values)
+ def validate(cmd, opts, values, orig)
Validate.constants.each do |name|
next if name == :Validator
const = Validate.const_get(name)
- const.new(cmd, opts, values).apply
+ const.new(cmd, opts, values, orig).apply
end
end
- class Validator < Struct.new(:cmd, :opts, :values)
+ class Validator < Struct.new(:cmd, :opts, :values, :orig)
include Regex
def compact(hash, *keys)
hash.reject { |_, value| value.nil? }.to_h
end
@@ -60,10 +60,10 @@
[opt.name, missing] if missing.any?
end.compact
end
def requires
- opts.select(&:requires?).select { |opt| values.key?(opt.name) }
+ opts.select(&:requires?).select { |opt| orig.key?(opt.name) }
end
end
class Format < Validator
def apply