Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Sunny_yiyi
Swagger Ui
提交
febd5ff5
S
Swagger Ui
项目概览
Sunny_yiyi
/
Swagger Ui
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Swagger Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
febd5ff5
编写于
7月 24, 2017
作者:
S
shockey
提交者:
GitHub
7月 24, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3452 from shockey/v/3.0.21
v3.0.21 (hotfix release)
上级
e45edc56
b8348335
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
109 addition
and
393 deletion
+109
-393
README.md
README.md
+1
-1
dist/swagger-ui-bundle.js
dist/swagger-ui-bundle.js
+3
-3
dist/swagger-ui-bundle.js.map
dist/swagger-ui-bundle.js.map
+1
-1
dist/swagger-ui.css
dist/swagger-ui.css
+1
-1
dist/swagger-ui.js
dist/swagger-ui.js
+1
-1
dist/swagger-ui.js.map
dist/swagger-ui.js.map
+1
-1
package.json
package.json
+1
-1
src/core/components/layout-utils.jsx
src/core/components/layout-utils.jsx
+3
-4
src/core/json-schema-components.js
src/core/json-schema-components.js
+11
-13
src/core/utils.js
src/core/utils.js
+45
-70
src/style/_buttons.scss
src/style/_buttons.scss
+1
-9
src/style/_form.scss
src/style/_form.scss
+6
-6
src/style/_mixins.scss
src/style/_mixins.scss
+0
-6
src/style/_table.scss
src/style/_table.scss
+0
-4
test/core/utils.js
test/core/utils.js
+34
-272
未找到文件。
README.md
浏览文件 @
febd5ff5
...
...
@@ -22,7 +22,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
3.
0.2
0 | 2017-07-21 | 2.0 |
[
tag v3.0.20
](
https://github.com/swagger-api/swagger-ui/tree/v3.0.20
)
|
3.
0.2
1 | 2017-07-24 | 2.0 |
[
tag v3.0.21
](
https://github.com/swagger-api/swagger-ui/tree/v3.0.21
)
|
2.
2.10 | 2017-01-04 | 1.1, 1.2, 2.0 |
[
tag v2.2.10
](
https://github.com/swagger-api/swagger-ui/tree/v2.2.10
)
|
2.
1.5 | 2016-07-20 | 1.1, 1.2, 2.0 |
[
tag v2.1.5
](
https://github.com/swagger-api/swagger-ui/tree/v2.1.5
)
|
2.
0.24 | 2014-09-12 | 1.1, 1.2 |
[
tag v2.0.24
](
https://github.com/swagger-api/swagger-ui/tree/v2.0.24
)
|
...
...
dist/swagger-ui-bundle.js
浏览文件 @
febd5ff5
此差异已折叠。
点击以展开。
dist/swagger-ui-bundle.js.map
浏览文件 @
febd5ff5
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AA4uEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAkqTA;;;;;;;;;;;;;;AA+5JA;;;;;;;;;AAmwnBA;;;;;AA+kQA;;;;;;AA+gXA","sourceRoot":""}
\ No newline at end of file
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AAmtEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAkqTA;;;;;;;;;;;;;;AA+5JA;;;;;;;;;AAkwnBA;;;;;AA6kQA;;;;;;AA+gXA","sourceRoot":""}
\ No newline at end of file
dist/swagger-ui.css
浏览文件 @
febd5ff5
此差异已折叠。
点击以展开。
dist/swagger-ui.js
浏览文件 @
febd5ff5
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
dist/swagger-ui.js.map
浏览文件 @
febd5ff5
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAw8aA","sourceRoot":""}
\ No newline at end of file
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA46aA","sourceRoot":""}
\ No newline at end of file
package.json
浏览文件 @
febd5ff5
{
"name"
:
"swagger-ui"
,
"version"
:
"3.0.2
0
"
,
"version"
:
"3.0.2
1
"
,
"main"
:
"dist/swagger-ui.js"
,
"repository"
:
"git@github.com:swagger-api/swagger-ui.git"
,
"contributors"
:
[
...
...
src/core/components/layout-utils.jsx
浏览文件 @
febd5ff5
...
...
@@ -129,8 +129,7 @@ export class Select extends React.Component {
value
:
PropTypes
.
any
,
onChange
:
PropTypes
.
func
,
multiple
:
PropTypes
.
bool
,
allowEmptyValue
:
PropTypes
.
bool
,
className
:
PropTypes
.
string
allowEmptyValue
:
PropTypes
.
bool
}
static
defaultProps
=
{
...
...
@@ -143,7 +142,7 @@ export class Select extends React.Component {
let
value
if
(
props
.
value
)
{
if
(
props
.
value
!==
undefined
)
{
value
=
props
.
value
}
else
{
value
=
props
.
multiple
?
[
""
]
:
""
...
...
@@ -179,7 +178,7 @@ export class Select extends React.Component {
let
value
=
this
.
state
.
value
.
toJS
?
this
.
state
.
value
.
toJS
()
:
this
.
state
.
value
return
(
<
select
className
=
{
this
.
props
.
className
}
multiple
=
{
multiple
}
value
=
{
value
}
onChange
=
{
this
.
onChange
}
>
<
select
multiple
=
{
multiple
}
value
=
{
value
}
onChange
=
{
this
.
onChange
}
>
{
allowEmptyValue
?
<
option
value
=
""
>
--
</
option
>
:
null
}
{
allowedValues
.
map
(
function
(
item
,
key
)
{
...
...
src/core/json-schema-components.js
浏览文件 @
febd5ff5
...
...
@@ -57,8 +57,7 @@ export class JsonSchema_string extends Component {
if
(
enumValue
)
{
const
Select
=
getComponent
(
"
Select
"
)
return
(
<
Select
className
=
{
errors
.
length
?
"
invalid
"
:
""
}
allowedValues
=
{
enumValue
}
return
(
<
Select
allowedValues
=
{
enumValue
}
value
=
{
value
}
allowEmptyValue
=
{
!
required
}
onChange
=
{
this
.
onEnumChange
}
/>
)
...
...
@@ -122,7 +121,6 @@ export class JsonSchema_array extends PureComponent {
render
()
{
let
{
getComponent
,
required
,
schema
,
fn
}
=
this
.
props
let
errors
=
schema
.
errors
||
[]
let
itemSchema
=
fn
.
inferSchema
(
schema
.
items
)
const
JsonSchemaForm
=
getComponent
(
"
JsonSchemaForm
"
)
...
...
@@ -133,17 +131,19 @@ export class JsonSchema_array extends PureComponent {
if
(
enumValue
)
{
const
Select
=
getComponent
(
"
Select
"
)
return
(
<
Select
className
=
{
errors
.
length
?
"
invalid
"
:
""
}
multiple
=
{
true
}
return
(
<
Select
multiple
=
{
true
}
value
=
{
value
}
allowedValues
=
{
enumValue
}
allowEmptyValue
=
{
!
required
}
onChange
=
{
this
.
onEnumChange
}
/>
)
}
let
errors
=
schema
.
errors
||
[]
return
(
<
div
>
{
!
value
||
value
.
count
()
<
1
?
null
:
{
!
value
||
value
.
count
()
<
1
?
(
errors
.
length
?
<
span
style
=
{{
color
:
"
red
"
,
fortWeight
:
"
bold
"
}}
>
{
errors
[
0
]
}
<
/span> : null
)
:
value
.
map
(
(
item
,
i
)
=>
{
let
schema
=
Object
.
assign
({},
itemSchema
)
if
(
errors
.
length
)
{
...
...
@@ -153,12 +153,12 @@ export class JsonSchema_array extends PureComponent {
return
(
<
div
key
=
{
i
}
className
=
"
json-schema-form-item
"
>
<
JsonSchemaForm
fn
=
{
fn
}
getComponent
=
{
getComponent
}
value
=
{
item
}
onChange
=
{(
val
)
=>
this
.
onItemChange
(
val
,
i
)}
schema
=
{
schema
}
/
>
<
Button
className
=
"
btn btn-sm
json-schema-form-item-remove
"
onClick
=
{()
=>
this
.
removeItem
(
i
)}
>
-
<
/Button
>
<
Button
className
=
"
json-schema-form-item-remove
"
onClick
=
{()
=>
this
.
removeItem
(
i
)}
>
-
<
/Button
>
<
/div
>
)
}).
toArray
()
}
<
Button
className
=
{
`btn btn-sm json-schema-form-item-add
${
errors
.
length
?
"
invalid
"
:
null
}
`
}
onClick
=
{
this
.
addItem
}
>
Add
item
<
/Button
>
<
Button
className
=
"
json-schema-form-item-add
"
onClick
=
{
this
.
addItem
}
>
Add
item
<
/Button
>
<
/div
>
)
}
...
...
@@ -170,14 +170,12 @@ export class JsonSchema_boolean extends Component {
onEnumChange
=
(
val
)
=>
this
.
props
.
onChange
(
val
)
render
()
{
let
{
getComponent
,
value
,
schema
}
=
this
.
props
let
errors
=
schema
.
errors
||
[]
let
{
getComponent
,
required
,
value
}
=
this
.
props
const
Select
=
getComponent
(
"
Select
"
)
return
(
<
Select
className
=
{
errors
.
length
?
"
invalid
"
:
""
}
value
=
{
String
(
value
)
}
return
(
<
Select
value
=
{
String
(
value
)
}
allowedValues
=
{
fromJS
([
"
true
"
,
"
false
"
])
}
allowEmptyValue
=
{
true
}
allowEmptyValue
=
{
!
required
}
onChange
=
{
this
.
onEnumChange
}
/>
)
}
}
src/core/utils.js
浏览文件 @
febd5ff5
...
...
@@ -468,18 +468,6 @@ export const validateFile = ( val ) => {
}
}
export
const
validateBoolean
=
(
val
)
=>
{
if
(
!
(
val
===
"
true
"
||
val
===
"
false
"
||
val
===
true
||
val
===
false
)
)
{
return
"
Value must be a boolean
"
}
}
export
const
validateString
=
(
val
)
=>
{
if
(
val
&&
typeof
val
!==
"
string
"
)
{
return
"
Value must be a string
"
}
}
// validation of parameters before execute
export
const
validateParam
=
(
param
,
isXml
)
=>
{
let
errors
=
[]
...
...
@@ -487,66 +475,53 @@ export const validateParam = (param, isXml) => {
let
required
=
param
.
get
(
"
required
"
)
let
type
=
param
.
get
(
"
type
"
)
// If the parameter is required OR the parameter has a value (meaning optional, but filled in)
// then we should do our validation routine
if
(
required
||
value
)
{
// These checks should evaluate to true if the parameter's value is valid
let
stringCheck
=
type
===
"
string
"
&&
value
&&
!
validateString
(
value
)
let
arrayCheck
=
type
===
"
array
"
&&
Array
.
isArray
(
value
)
&&
value
.
length
let
listCheck
=
type
===
"
array
"
&&
Im
.
List
.
isList
(
value
)
&&
value
.
count
()
let
fileCheck
=
type
===
"
file
"
&&
value
instanceof
win
.
File
let
booleanCheck
=
type
===
"
boolean
"
&&
!
validateBoolean
(
value
)
let
numberCheck
=
type
===
"
number
"
&&
!
validateNumber
(
value
)
// validateNumber returns undefined if the value is a number
let
integerCheck
=
type
===
"
integer
"
&&
!
validateInteger
(
value
)
// validateInteger returns undefined if the value is an integer
if
(
required
&&
!
(
stringCheck
||
arrayCheck
||
listCheck
||
fileCheck
||
booleanCheck
||
numberCheck
||
integerCheck
)
)
{
errors
.
push
(
"
Required field is not provided
"
)
return
errors
}
let
stringCheck
=
type
===
"
string
"
&&
!
value
let
arrayCheck
=
type
===
"
array
"
&&
Array
.
isArray
(
value
)
&&
!
value
.
length
let
listCheck
=
type
===
"
array
"
&&
Im
.
List
.
isList
(
value
)
&&
!
value
.
count
()
let
fileCheck
=
type
===
"
file
"
&&
!
(
value
instanceof
win
.
File
)
let
nullUndefinedCheck
=
value
===
null
||
value
===
undefined
if
(
type
===
"
string
"
)
{
let
err
=
validateString
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
boolean
"
)
{
let
err
=
validateBoolean
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
number
"
)
{
let
err
=
validateNumber
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
integer
"
)
{
let
err
=
validateInteger
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
array
"
)
{
let
itemType
if
(
!
value
.
count
()
)
{
return
errors
}
itemType
=
param
.
getIn
([
"
items
"
,
"
type
"
])
value
.
forEach
((
item
,
index
)
=>
{
let
err
if
(
itemType
===
"
number
"
)
{
err
=
validateNumber
(
item
)
}
else
if
(
itemType
===
"
integer
"
)
{
err
=
validateInteger
(
item
)
}
else
if
(
itemType
===
"
string
"
)
{
err
=
validateString
(
item
)
}
if
(
required
&&
(
stringCheck
||
arrayCheck
||
listCheck
||
fileCheck
||
nullUndefinedCheck
)
)
{
errors
.
push
(
"
Required field is not provided
"
)
return
errors
}
if
(
err
)
{
errors
.
push
({
index
:
index
,
error
:
err
})
}
})
}
else
if
(
type
===
"
file
"
)
{
let
err
=
validateFile
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
if
(
value
===
null
||
value
===
undefined
)
{
return
errors
}
if
(
type
===
"
number
"
)
{
let
err
=
validateNumber
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
integer
"
)
{
let
err
=
validateInteger
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
else
if
(
type
===
"
array
"
)
{
let
itemType
if
(
!
value
.
count
()
)
{
return
errors
}
itemType
=
param
.
getIn
([
"
items
"
,
"
type
"
])
value
.
forEach
((
item
,
index
)
=>
{
let
err
if
(
itemType
===
"
number
"
)
{
err
=
validateNumber
(
item
)
}
else
if
(
itemType
===
"
integer
"
)
{
err
=
validateInteger
(
item
)
}
if
(
err
)
{
errors
.
push
({
index
:
index
,
error
:
err
})
}
})
}
else
if
(
type
===
"
file
"
)
{
let
err
=
validateFile
(
value
)
if
(
!
err
)
return
errors
errors
.
push
(
err
)
}
return
errors
...
...
src/style/_buttons.scss
浏览文件 @
febd5ff5
...
...
@@ -14,11 +14,6 @@
@include
text_headline
();
&
.btn-sm
{
font-size
:
12px
;
padding
:
4px
23px
;
}
&
[
disabled
]
{
cursor
:
not
-
allowed
;
...
...
@@ -170,9 +165,6 @@
button
{
cursor
:
pointer
;
outline
:
none
;
&
.invalid
{
@include
invalidFormElement
();
}
outline
:
none
;
}
src/style/_form.scss
浏览文件 @
febd5ff5
...
...
@@ -21,10 +21,6 @@ select
background
:
#f7f7f7
;
}
&
.invalid
{
@include
invalidFormElement
();
}
}
.opblock-body
select
...
...
@@ -57,8 +53,12 @@ input[type=file]
border-radius
:
4px
;
background
:
#fff
;
&
.invalid
{
@include
invalidFormElement
();
&
.invalid
{
animation
:
shake
.4s
1
;
border-color
:
$_color-delete
;
background
:
lighten
(
$_color-delete
,
35%
);
}
}
...
...
src/style/_mixins.scss
浏览文件 @
febd5ff5
...
...
@@ -166,9 +166,3 @@ $browser-context: 16;
@warn
'Breakpoint mixin supports: tablet, mobile, desktop'
;
}
}
@mixin
invalidFormElement
()
{
animation
:
shake
.4s
1
;
border-color
:
$_color-delete
;
background
:
lighten
(
$_color-delete
,
35%
);
}
src/style/_table.scss
浏览文件 @
febd5ff5
...
...
@@ -97,10 +97,6 @@ table
width
:
100%
;
max-width
:
340px
;
}
select
{
border-width
:
1px
;
}
}
.parameter__name
...
...
test/core/utils.js
浏览文件 @
febd5ff5
...
...
@@ -176,7 +176,6 @@ describe("utils", function() {
let
result
=
null
it
(
"
validates required strings
"
,
function
()
{
// invalid string
param
=
fromJS
({
required
:
true
,
type
:
"
string
"
,
...
...
@@ -184,39 +183,9 @@ describe("utils", function() {
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// valid string
param
=
fromJS
({
required
:
true
,
type
:
"
string
"
,
value
:
"
test string
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates optional strings
"
,
function
()
{
// valid (empty) string
param
=
fromJS
({
required
:
false
,
type
:
"
string
"
,
value
:
""
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// valid string
param
=
fromJS
({
required
:
false
,
type
:
"
string
"
,
value
:
"
test
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates required files
"
,
function
()
{
// invalid file
param
=
fromJS
({
required
:
true
,
type
:
"
file
"
,
...
...
@@ -224,48 +193,9 @@ describe("utils", function() {
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// valid file
param
=
fromJS
({
required
:
true
,
type
:
"
file
"
,
value
:
new
win
.
File
()
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates optional files
"
,
function
()
{
// invalid file
param
=
fromJS
({
required
:
false
,
type
:
"
file
"
,
value
:
"
not a file
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Value must be a file
"
]
)
// valid (empty) file
param
=
fromJS
({
required
:
false
,
type
:
"
file
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// valid file
param
=
fromJS
({
required
:
false
,
type
:
"
file
"
,
value
:
new
win
.
File
()
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates required arrays
"
,
function
()
{
// invalid (empty) array
param
=
fromJS
({
required
:
true
,
type
:
"
array
"
,
...
...
@@ -274,191 +204,17 @@ describe("utils", function() {
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// invalid (not an array)
param
=
fromJS
({
required
:
true
,
type
:
"
array
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// invalid array, items do not match correct type
param
=
fromJS
({
required
:
true
,
type
:
"
array
"
,
value
:
[
1
],
items
:
{
type
:
"
string
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[{
index
:
0
,
error
:
"
Value must be a string
"
}]
)
// valid array, with no 'type' for items
param
=
fromJS
({
required
:
true
,
type
:
"
array
"
,
value
:
[
"
1
"
]
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// valid array, items match type
param
=
fromJS
({
required
:
true
,
type
:
"
array
"
,
value
:
[
"
1
"
],
items
:
{
type
:
"
string
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates optional arrays
"
,
function
()
{
// valid, empty array
param
=
fromJS
({
required
:
false
,
type
:
"
array
"
,
value
:
[]
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// invalid, items do not match correct type
param
=
fromJS
({
required
:
false
,
type
:
"
array
"
,
value
:
[
"
number
"
],
items
:
{
type
:
"
number
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[{
index
:
0
,
error
:
"
Value must be a number
"
}]
)
// valid
param
=
fromJS
({
required
:
false
,
type
:
"
array
"
,
value
:
[
"
test
"
],
items
:
{
type
:
"
string
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates required booleans
"
,
function
()
{
// invalid boolean value
param
=
fromJS
({
required
:
true
,
type
:
"
boolean
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// invalid boolean value (not a boolean)
param
=
fromJS
({
required
:
true
,
type
:
"
boolean
"
,
value
:
"
test string
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// valid boolean value
param
=
fromJS
({
required
:
true
,
type
:
"
boolean
"
,
value
:
"
true
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// valid boolean value
param
=
fromJS
({
required
:
true
,
type
:
"
boolean
"
,
value
:
false
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates optional booleans
"
,
function
()
{
// valid (empty) boolean value
param
=
fromJS
({
required
:
false
,
type
:
"
boolean
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// invalid boolean value (not a boolean)
param
=
fromJS
({
required
:
false
,
type
:
"
boolean
"
,
value
:
"
test string
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Value must be a boolean
"
]
)
// valid boolean value
param
=
fromJS
({
required
:
false
,
type
:
"
boolean
"
,
value
:
"
true
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
// valid boolean value
param
=
fromJS
({
required
:
false
,
type
:
"
boolean
"
,
value
:
false
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates required numbers
"
,
function
()
{
// invalid number, string instead of a number
param
=
fromJS
({
required
:
true
,
type
:
"
number
"
,
value
:
"
test
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// invalid number, undefined value
param
=
fromJS
({
required
:
true
,
type
:
"
number
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
// valid number
param
=
fromJS
({
required
:
true
,
type
:
"
number
"
,
value
:
10
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates optional numbers
"
,
function
()
{
// invalid number, string instead of a number
it
(
"
validates numbers
"
,
function
()
{
// string instead of a number
param
=
fromJS
({
required
:
false
,
type
:
"
number
"
,
...
...
@@ -467,7 +223,7 @@ describe("utils", function() {
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Value must be a number
"
]
)
//
valid (empty) number
//
undefined value
param
=
fromJS
({
required
:
false
,
type
:
"
number
"
,
...
...
@@ -476,72 +232,78 @@ describe("utils", function() {
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
//
valid number
//
null value
param
=
fromJS
({
required
:
false
,
type
:
"
number
"
,
value
:
10
value
:
null
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates
required
integers
"
,
function
()
{
//
invalid integer, string instead of an
integer
it
(
"
validates integers
"
,
function
()
{
//
string instead of
integer
param
=
fromJS
({
required
:
tru
e
,
required
:
fals
e
,
type
:
"
integer
"
,
value
:
"
test
"
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
expect
(
result
).
toEqual
(
[
"
Value must be an integer
"
]
)
//
invalid integer,
undefined value
// undefined value
param
=
fromJS
({
required
:
tru
e
,
required
:
fals
e
,
type
:
"
integer
"
,
value
:
undefined
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Required field is not provided
"
]
)
expect
(
result
).
toEqual
(
[]
)
//
valid integer
//
null value
param
=
fromJS
({
required
:
tru
e
,
required
:
fals
e
,
type
:
"
integer
"
,
value
:
10
value
:
null
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
})
it
(
"
validates
optional integer
s
"
,
function
()
{
//
invalid integer, string instead of an integer
it
(
"
validates
array
s
"
,
function
()
{
//
empty array
param
=
fromJS
({
required
:
false
,
type
:
"
integer
"
,
value
:
"
test
"
type
:
"
array
"
,
value
:
[]
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[
"
Value must be an integer
"
]
)
expect
(
result
).
toEqual
(
[]
)
//
valid (empty) integer
//
numbers
param
=
fromJS
({
required
:
false
,
type
:
"
integer
"
,
value
:
undefined
type
:
"
array
"
,
value
:
[
"
number
"
],
items
:
{
type
:
"
number
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
expect
(
result
).
toEqual
(
[
{
index
:
0
,
error
:
"
Value must be a number
"
}
]
)
//
valid number
//
integers
param
=
fromJS
({
required
:
false
,
type
:
"
integer
"
,
value
:
10
type
:
"
array
"
,
value
:
[
"
not
"
,
"
numbers
"
],
items
:
{
type
:
"
integer
"
}
})
result
=
validateParam
(
param
,
false
)
expect
(
result
).
toEqual
(
[]
)
expect
(
result
).
toEqual
(
[
{
index
:
0
,
error
:
"
Value must be an integer
"
},
{
index
:
1
,
error
:
"
Value must be an integer
"
}
]
)
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录