grape
grape copied to clipboard
Optional parameter with a message attribute exception
It probably never happened but defining a optional parameter with a message attribute will raise an exception.
The following test will fail.
context 'optional param with message' do
let(:app) do
Class.new(described_class) do
params do
optional 'test', message: 'is required'
end
get 'test'
end
end
before do
end
it 'should return a message' do
expect { get 'test' }.not_to raise_error
end
end
It's an easy fix where we need to remove the message key even if presence is not required.
@wwqwq2313 almost, but since :message act only on required field, we just need to delete it on optional field. Also, when adding :presence, we should delete the :message the validations.
I think @wwqwq2313 is an AI (!)
@dblock yeah I know. I just wanted to know if it would respond back after my comment.