Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0177cbae
Commit
0177cbae
authored
Dec 22, 2016
by
Xing Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error messages for ValidateObject method.
Improved error messages for method #ValidateObject in pkg/api/validation/schema.go.
parent
13424d87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
schema.go
pkg/api/validation/schema.go
+3
-3
No files found.
pkg/api/validation/schema.go
View file @
0177cbae
...
@@ -281,7 +281,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
...
@@ -281,7 +281,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
// handle required fields
// handle required fields
for
_
,
requiredKey
:=
range
model
.
Required
{
for
_
,
requiredKey
:=
range
model
.
Required
{
if
_
,
ok
:=
fields
[
requiredKey
];
!
ok
{
if
_
,
ok
:=
fields
[
requiredKey
];
!
ok
{
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"field %s
for %s: is required"
,
requiredKey
,
typeName
))
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"field %s
%s for %s is required"
,
fieldName
,
requiredKey
,
typeName
))
}
}
}
}
for
key
,
value
:=
range
fields
{
for
key
,
value
:=
range
fields
{
...
@@ -302,7 +302,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
...
@@ -302,7 +302,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
continue
continue
}
}
if
details
.
Type
==
nil
&&
details
.
Ref
==
nil
{
if
details
.
Type
==
nil
&&
details
.
Ref
==
nil
{
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"could not find the type of %s
from object: %v"
,
key
,
details
))
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"could not find the type of %s
%s from object %v"
,
fieldName
,
key
,
details
))
}
}
var
fieldType
string
var
fieldType
string
if
details
.
Type
!=
nil
{
if
details
.
Type
!=
nil
{
...
@@ -311,7 +311,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
...
@@ -311,7 +311,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
fieldType
=
*
details
.
Ref
fieldType
=
*
details
.
Ref
}
}
if
value
==
nil
{
if
value
==
nil
{
glog
.
V
(
2
)
.
Infof
(
"Skipping nil field: %s
"
,
key
)
glog
.
V
(
2
)
.
Infof
(
"Skipping nil field: %s
%s"
,
fieldName
,
key
)
continue
continue
}
}
errs
:=
s
.
validateField
(
value
,
fieldName
+
key
,
fieldType
,
&
details
)
errs
:=
s
.
validateField
(
value
,
fieldName
+
key
,
fieldType
,
&
details
)
...
...
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