14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/lite/command/internals/attributes.rb', line 14
def required(*attributes, from: :context, **options)
delegate(*attributes, from:)
validates_each(*attributes, **options) do |command, method_name, _attr_value|
next unless Utils.evaluate(command, options)
next if command.errors.added?(from, :undefined) || command.errors.added?(method_name, :required)
if !command.respond_to?(from, true)
command.errors.add(from, :undefined, message: "is an undefined argument")
elsif !command.send(from).respond_to?(method_name, true)
command.errors.add(method_name, :required, message: "is a required argument")
end
end
end
|