Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Sunny_yiyi
Swagger Ui
提交
4cbae095
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,发现更多精彩内容 >>
未验证
提交
4cbae095
编写于
7月 29, 2020
作者:
H
Helen Kosova
提交者:
GitHub
7月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(try-it-out): Better tooltips for min/max validations (#6266)
上级
bd9117da
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
30 deletion
+23
-30
src/core/utils.js
src/core/utils.js
+4
-4
test/mocha/core/utils.js
test/mocha/core/utils.js
+19
-26
未找到文件。
src/core/utils.js
浏览文件 @
4cbae095
...
@@ -325,13 +325,13 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
...
@@ -325,13 +325,13 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
export
const
validateMaximum
=
(
val
,
max
)
=>
{
export
const
validateMaximum
=
(
val
,
max
)
=>
{
if
(
val
>
max
)
{
if
(
val
>
max
)
{
return
"
Value must be less than Maximum
"
return
`Value must be less than
${
max
}
`
}
}
}
}
export
const
validateMinimum
=
(
val
,
min
)
=>
{
export
const
validateMinimum
=
(
val
,
min
)
=>
{
if
(
val
<
min
)
{
if
(
val
<
min
)
{
return
"
Value must be greater than Minimum
"
return
`Value must be greater than
${
min
}
`
}
}
}
}
...
@@ -380,13 +380,13 @@ export const validateGuid = (val) => {
...
@@ -380,13 +380,13 @@ export const validateGuid = (val) => {
export
const
validateMaxLength
=
(
val
,
max
)
=>
{
export
const
validateMaxLength
=
(
val
,
max
)
=>
{
if
(
val
.
length
>
max
)
{
if
(
val
.
length
>
max
)
{
return
"
Value must be less than MaxLength
"
return
`Value must be no longer than
${
max
}
character
${
max
!==
1
?
"
s
"
:
""
}
`
}
}
}
}
export
const
validateMinLength
=
(
val
,
min
)
=>
{
export
const
validateMinLength
=
(
val
,
min
)
=>
{
if
(
val
.
length
<
min
)
{
if
(
val
.
length
<
min
)
{
return
"
Value must be greater than MinLength
"
return
`Value must be at least
${
min
}
character
${
min
!==
1
?
"
s
"
:
""
}
`
}
}
}
}
...
...
test/mocha/core/utils.js
浏览文件 @
4cbae095
...
@@ -135,32 +135,28 @@ describe("utils", function() {
...
@@ -135,32 +135,28 @@ describe("utils", function() {
})
})
describe
(
"
validateMaximum
"
,
function
()
{
describe
(
"
validateMaximum
"
,
function
()
{
let
errorMessage
=
"
Value must be less than Maximum
"
it
(
"
doesn't return for valid input
"
,
function
()
{
it
(
"
doesn't return for valid input
"
,
function
()
{
expect
(
validateMaximum
(
9
,
10
)).
toBeFalsy
()
expect
(
validateMaximum
(
9
,
10
)).
toBeFalsy
()
expect
(
validateMaximum
(
19
,
20
)).
toBeFalsy
()
expect
(
validateMaximum
(
19
,
20
)).
toBeFalsy
()
})
})
it
(
"
returns a message for invalid input
"
,
function
()
{
it
(
"
returns a message for invalid input
"
,
function
()
{
expect
(
validateMaximum
(
1
,
0
)).
toEqual
(
errorMessage
)
expect
(
validateMaximum
(
1
,
0
)).
toEqual
(
"
Value must be less than 0
"
)
expect
(
validateMaximum
(
10
,
9
)).
toEqual
(
errorMessage
)
expect
(
validateMaximum
(
10
,
9
)).
toEqual
(
"
Value must be less than 9
"
)
expect
(
validateMaximum
(
20
,
19
)).
toEqual
(
errorMessage
)
expect
(
validateMaximum
(
20
,
19
)).
toEqual
(
"
Value must be less than 19
"
)
})
})
})
})
describe
(
"
validateMinimum
"
,
function
()
{
describe
(
"
validateMinimum
"
,
function
()
{
let
errorMessage
=
"
Value must be greater than Minimum
"
it
(
"
doesn't return for valid input
"
,
function
()
{
it
(
"
doesn't return for valid input
"
,
function
()
{
expect
(
validateMinimum
(
2
,
1
)).
toBeFalsy
()
expect
(
validateMinimum
(
2
,
1
)).
toBeFalsy
()
expect
(
validateMinimum
(
20
,
10
)).
toBeFalsy
()
expect
(
validateMinimum
(
20
,
10
)).
toBeFalsy
()
})
})
it
(
"
returns a message for invalid input
"
,
function
()
{
it
(
"
returns a message for invalid input
"
,
function
()
{
expect
(
validateMinimum
(
-
1
,
0
)).
toEqual
(
errorMessage
)
expect
(
validateMinimum
(
-
1
,
0
)).
toEqual
(
"
Value must be greater than 0
"
)
expect
(
validateMinimum
(
1
,
2
)).
toEqual
(
errorMessage
)
expect
(
validateMinimum
(
1
,
2
)).
toEqual
(
"
Value must be greater than 2
"
)
expect
(
validateMinimum
(
10
,
20
)).
toEqual
(
errorMessage
)
expect
(
validateMinimum
(
10
,
20
)).
toEqual
(
"
Value must be greater than 20
"
)
})
})
})
})
...
@@ -295,31 +291,28 @@ describe("utils", function() {
...
@@ -295,31 +291,28 @@ describe("utils", function() {
})
})
describe
(
"
validateMaxLength
"
,
function
()
{
describe
(
"
validateMaxLength
"
,
function
()
{
let
errorMessage
=
"
Value must be less than MaxLength
"
it
(
"
doesn't return for valid input
"
,
function
()
{
it
(
"
doesn't return for valid guid
"
,
function
()
{
expect
(
validateMaxLength
(
"
a
"
,
1
)).
toBeFalsy
()
expect
(
validateMaxLength
(
"
a
"
,
1
)).
toBeFalsy
()
expect
(
validateMaxLength
(
"
abc
"
,
5
)).
toBeFalsy
()
expect
(
validateMaxLength
(
"
abc
"
,
5
)).
toBeFalsy
()
})
})
it
(
"
returns a message for invalid input'
"
,
function
()
{
it
(
"
returns a message for invalid input'
"
,
function
()
{
expect
(
validateMaxLength
(
"
abc
"
,
0
)).
toEqual
(
errorMessage
)
expect
(
validateMaxLength
(
"
abc
"
,
0
)).
toEqual
(
"
Value must be no longer than 0 characters
"
)
expect
(
validateMaxLength
(
"
abc
"
,
1
)).
toEqual
(
errorMessage
)
expect
(
validateMaxLength
(
"
abc
"
,
1
)).
toEqual
(
"
Value must be no longer than 1 character
"
)
expect
(
validateMaxLength
(
"
abc
"
,
2
)).
toEqual
(
errorMessage
)
expect
(
validateMaxLength
(
"
abc
"
,
2
)).
toEqual
(
"
Value must be no longer than 2 characters
"
)
})
})
})
})
describe
(
"
validateMinLength
"
,
function
()
{
describe
(
"
validateMinLength
"
,
function
()
{
let
errorMessage
=
"
Value must be greater than MinLength
"
it
(
"
doesn't return for valid input
"
,
function
()
{
it
(
"
doesn't return for valid guid
"
,
function
()
{
expect
(
validateMinLength
(
"
a
"
,
1
)).
toBeFalsy
()
expect
(
validateMinLength
(
"
a
"
,
1
)).
toBeFalsy
()
expect
(
validateMinLength
(
"
abc
"
,
2
)).
toBeFalsy
()
expect
(
validateMinLength
(
"
abc
"
,
2
)).
toBeFalsy
()
})
})
it
(
"
returns a message for invalid input'
"
,
function
()
{
it
(
"
returns a message for invalid input'
"
,
function
()
{
expect
(
validateMinLength
(
"
abc
"
,
5
)).
toEqual
(
errorMessage
)
expect
(
validateMinLength
(
""
,
1
)).
toEqual
(
"
Value must be at least 1 character
"
)
expect
(
validateMinLength
(
"
abc
"
,
8
)).
toEqual
(
errorMessage
)
expect
(
validateMinLength
(
"
abc
"
,
5
)).
toEqual
(
"
Value must be at least 5 characters
"
)
expect
(
validateMinLength
(
"
abc
"
,
8
)).
toEqual
(
"
Value must be at least 8 characters
"
)
})
})
})
})
...
@@ -616,7 +609,7 @@ describe("utils", function() {
...
@@ -616,7 +609,7 @@ describe("utils", function() {
maxLength
:
5
maxLength
:
5
}
}
value
=
"
test string
"
value
=
"
test string
"
assertValidateParam
(
param
,
value
,
[
"
Value must be
less than MaxLength
"
])
assertValidateParam
(
param
,
value
,
[
"
Value must be
no longer than 5 characters
"
])
// invalid string with max length 0
// invalid string with max length 0
param
=
{
param
=
{
...
@@ -625,7 +618,7 @@ describe("utils", function() {
...
@@ -625,7 +618,7 @@ describe("utils", function() {
maxLength
:
0
maxLength
:
0
}
}
value
=
"
test string
"
value
=
"
test string
"
assertValidateParam
(
param
,
value
,
[
"
Value must be
less than MaxLength
"
])
assertValidateParam
(
param
,
value
,
[
"
Value must be
no longer than 0 characters
"
])
// invalid string with min length
// invalid string with min length
param
=
{
param
=
{
...
@@ -634,7 +627,7 @@ describe("utils", function() {
...
@@ -634,7 +627,7 @@ describe("utils", function() {
minLength
:
50
minLength
:
50
}
}
value
=
"
test string
"
value
=
"
test string
"
assertValidateParam
(
param
,
value
,
[
"
Value must be
greater than MinLength
"
])
assertValidateParam
(
param
,
value
,
[
"
Value must be
at least 50 characters
"
])
})
})
it
(
"
validates optional strings
"
,
function
()
{
it
(
"
validates optional strings
"
,
function
()
{
...
@@ -908,7 +901,7 @@ describe("utils", function() {
...
@@ -908,7 +901,7 @@ describe("utils", function() {
maximum
:
0
maximum
:
0
}
}
value
=
1
value
=
1
assertValidateParam
(
param
,
value
,
[
"
Value must be less than
Maximum
"
])
assertValidateParam
(
param
,
value
,
[
"
Value must be less than
0
"
])
// invalid number with minimum:0
// invalid number with minimum:0
param
=
{
param
=
{
...
@@ -917,7 +910,7 @@ describe("utils", function() {
...
@@ -917,7 +910,7 @@ describe("utils", function() {
minimum
:
0
minimum
:
0
}
}
value
=
-
10
value
=
-
10
assertValidateParam
(
param
,
value
,
[
"
Value must be greater than
Minimum
"
])
assertValidateParam
(
param
,
value
,
[
"
Value must be greater than
0
"
])
})
})
it
(
"
validates optional numbers
"
,
function
()
{
it
(
"
validates optional numbers
"
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录