I have a form. where file upload is mandatory. Validation works fine first time no file uploaded, but when i upload and delete file, Form doesn't throw validation error. Here is stakbiz https://stackblitz.com/edit/react-x27nfd
CodePudding user response:
You can use getValueFromEvent
prop on Form.Item
component like this:
const normFile = (e) => {
if (Array.isArray(e)) {
return e;
}
return e && e.fileList;
};
...
<Form.Item
label="File"
name="file"
getValueFromEvent={normFile}
rules={[
{
required: true,
message: 'Please input your File!',
},
]}
>
...
</Form.Item>
Here is edited version of your stackblitz link.