Skip to content

Commit 467e3e6

Browse files
[frontend] Mandatory file for Artifact creation (#8794)
1 parent 830ef4a commit 467e3e6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

opencti-platform/opencti-front/src/private/components/observations/stix_cyber_observables/StixCyberObservableCreation.jsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@ const StixCyberObservableCreation = ({
574574
is: (a, b, c, d) => !a && !b && !c && !d,
575575
then: () => Yup.string().required(t_i18n('MD5, SHA-1, SHA-256, SHA-512, or name is required')),
576576
}),
577+
file: Yup.mixed().when([], {
578+
is: () => status.type === 'Artifact',
579+
then: () => Yup.mixed().required(t_i18n('This field is required')),
580+
otherwise: () => Yup.mixed().nullable(),
581+
}),
577582
};
578583

579584
requiredOneOfFields = [
@@ -628,6 +633,7 @@ const StixCyberObservableCreation = ({
628633
setFieldValue,
629634
values,
630635
resetForm,
636+
errors,
631637
}) => (
632638
<>
633639
{bulkConf && (
@@ -848,10 +854,9 @@ const StixCyberObservableCreation = ({
848854
setFieldValue={setFieldValue}
849855
values={values.externalReferences}
850856
/>
851-
<Field
852-
component={CustomFileUploader}
853-
name="file"
857+
<CustomFileUploader
854858
setFieldValue={setFieldValue}
859+
formikErrors={errors}
855860
disabled={bulkConf && bulkSelectedKey && splitMultilines(values[bulkSelectedKey]).length > 1}
856861
noFileSelectedLabel={bulkConf && bulkSelectedKey && splitMultilines(values[bulkSelectedKey]).length > 1
857862
? t_i18n('File upload not allowed in bulk creation')

0 commit comments

Comments
 (0)