Skip to content

Commit

Permalink
color validation allow “” as value
Browse files Browse the repository at this point in the history
  • Loading branch information
FateRiddle committed Sep 27, 2020
1 parent 9e8179b commit 384bb2b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/demo/FR2/index.jsx
Expand Up @@ -7,7 +7,7 @@ import { Button } from 'antd';
const Demo = ({ schema = {} }) => {
const [formData, setFormData] = useState(() => schema.formData);
const [valid, setValid] = useState([]);
const [showValid, setShowValid] = useState(false);
const [showValid, setShowValid] = useState(true);

// useEffect(() => {
// setTimeout(() => setFormData({ crowd: { upfIdList: 'sdfsdf' } }), 1500);
Expand Down
5 changes: 5 additions & 0 deletions docs/demo/new-feature/test.json
Expand Up @@ -10,6 +10,11 @@
"title": "测试效验",
"type": "string",
"ui:hidden": "{{formData.string!=='2'}}"
},
"color": {
"title": "颜色选择",
"type": "string",
"format": "color"
}
},
"required": ["string22"]
Expand Down
3 changes: 1 addition & 2 deletions src/base/validate.js
Expand Up @@ -88,8 +88,7 @@ export const getValidateText = (obj = {}) => {
// TODO: 为了一个Color引入了一个挺大的包,可以优化
if (format === 'color' || widget === 'color') {
try {
// if (!finalValue) return '请填写正确的颜色格式';
Color(finalValue);
Color(finalValue || null); // 空字符串无法解析会报错,出现空的情况传 null
} catch (e) {
return '请填写正确的颜色格式';
}
Expand Down

0 comments on commit 384bb2b

Please sign in to comment.