Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
3a84a815
Commit
3a84a815
authored
Jan 05, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复 required 不触发的问题
parent
c9136e62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
index.tsx
src/components/NiceForm/index.tsx
+13
-2
No files found.
src/components/NiceForm/index.tsx
View file @
3a84a815
...
...
@@ -57,6 +57,17 @@ const SchemaSubmit = createVirtualBox('schemaSubmit', Submit)
const
SchemaReset
=
createVirtualBox
(
'schemaReset'
,
Reset
)
export
const
FlexBox
=
createVirtualBox
(
'flexBox'
,
props
=>
<
Row
{
...
props
}
/>)
export
const
isFieldLegal
=
(
value
:
any
):
boolean
=>
{
if
(
Array
.
isArray
(
value
)
&&
!
value
.
length
)
{
return
false
;
}
// 校验数值 及 字符串数值,这里主要是处理 数值 0 是合法的问题
if
(
!
isNaN
(
parseFloat
(
value
)))
{
return
true
;
}
return
!!
value
;
};
// 自定义校验规则
registerValidationRules
({
limitByte
:
(
value
,
desc
,
rules
)
=>
{
...
...
@@ -71,12 +82,12 @@ registerValidationRules({
},
required
:
(
value
,
desc
,
rules
)
=>
{
const
{
required
}
=
desc
;
let
str
=
value
;
let
message
=
``
if
(
required
)
{
message
+=
`
${
intl
.
formatMessage
({
id
:
'common.bitian'
})}
`
}
return
(
required
&&
str
===
null
)
?
message
:
''
console
.
log
(
'message'
,
message
);
return
(
required
&&
!
isFieldLegal
(
value
))
?
message
:
''
}
});
...
...
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