Commit 3a84a815 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复 required 不触发的问题

parent c9136e62
......@@ -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 : ''
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment