Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a002f784
authored
2015-03-27 23:04:07 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #1097 from pylemon/develop
form required validate for bool field bugfix
2 parents
cdf9ff40
caa260f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
validation/validation_test.go
validation/validators.go
validation/validation_test.go
View file @
a002f78
...
...
@@ -26,6 +26,12 @@ func TestRequired(t *testing.T) {
if
valid
.
Required
(
nil
,
"nil"
)
.
Ok
{
t
.
Error
(
"nil object should be false"
)
}
if
!
valid
.
Required
(
true
,
"bool"
)
.
Ok
{
t
.
Error
(
"Bool value should always return true"
)
}
if
!
valid
.
Required
(
false
,
"bool"
)
.
Ok
{
t
.
Error
(
"Bool value should always return true"
)
}
if
valid
.
Required
(
""
,
"string"
)
.
Ok
{
t
.
Error
(
"
\"
'
\"
string should be false"
)
}
...
...
validation/validators.go
View file @
a002f78
...
...
@@ -64,8 +64,8 @@ func (r Required) IsSatisfied(obj interface{}) bool {
if
str
,
ok
:=
obj
.
(
string
);
ok
{
return
len
(
str
)
>
0
}
if
b
,
ok
:=
obj
.
(
bool
);
ok
{
return
b
if
_
,
ok
:=
obj
.
(
bool
);
ok
{
return
true
}
if
i
,
ok
:=
obj
.
(
int
);
ok
{
return
i
!=
0
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment