Commit a8c5275f authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: add item external id validation

parent e887b250
Pipeline #180881 passed with stage
in 5 minutes and 15 seconds
......@@ -201,6 +201,48 @@ export function validateCommonFormFields<
})
}
if (values.externalIds !== undefined) {
values.externalIds.forEach((id, index) => {
if (
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier == null
) {
if (errors.externalIds === undefined) {
/* @ts-expect-error Untyped empty array. */
errors.externalIds = []
}
errors.externalIds[index] = {
identifier: 'ID is required.',
}
}
})
}
if (values.externalIds !== undefined) {
values.externalIds.forEach((id, index) => {
if (
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier == null
) {
if (errors.externalIds === undefined) {
/* @ts-expect-error Untyped empty array. */
errors.externalIds = []
}
errors.externalIds[index] = {
serviceIdentifier: 'Please select an ID service.',
}
}
})
}
/** `sourceItemId` is required when `source` is set. */
if (values.source?.id != null && values.sourceItemId == null) {
errors.sourceItemId = 'Missing value in Source ID.'
......
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