Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9d26c3f3
Commit
9d26c3f3
authored
Apr 04, 2022
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle nil values in Grape length limit validator
Changelog: fixed
parent
68467582
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
lib/api/validations/validators/limit.rb
lib/api/validations/validators/limit.rb
+1
-1
spec/lib/api/validations/validators/limit_spec.rb
spec/lib/api/validations/validators/limit_spec.rb
+6
-0
No files found.
lib/api/validations/validators/limit.rb
View file @
9d26c3f3
...
...
@@ -7,7 +7,7 @@ module API
def
validate_param!
(
attr_name
,
params
)
value
=
params
[
attr_name
]
return
if
value
.
size
<=
@option
return
if
value
.
nil?
||
value
.
size
<=
@option
raise
Grape
::
Exceptions
::
Validation
.
new
(
params:
[
@scope
.
full_name
(
attr_name
)],
...
...
spec/lib/api/validations/validators/limit_spec.rb
View file @
9d26c3f3
...
...
@@ -22,4 +22,10 @@ RSpec.describe API::Validations::Validators::Limit do
expect_validation_error
(
'test'
=>
"
#{
'a'
*
256
}
"
)
end
end
context
'value is nil'
do
it
'does not raise a validation error'
do
expect_no_validation_error
(
'test'
=>
nil
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment