14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/lite/command/internals/attributes.rb', line 14
def required(*attributes, from: :context, **options)
delegates(*attributes, from:)
validates_each(*attributes, **options) do |command, method_name, _attr_value|
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
|