fix: resource label value validation

This commit is contained in:
jialin
2024-09-14 19:49:22 +08:00
parent 0adca93d5c
commit 1fe42a6eda
6 changed files with 34 additions and 4 deletions
@@ -146,7 +146,9 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
id: 'common.validate.value'
},
{
name: 'models.form.selector'
name: intl.formatMessage({
id: 'models.form.selector'
})
}
)
);
@@ -3,6 +3,7 @@ import ModalFooter from '@/components/modal-footer';
import SealInput from '@/components/seal-form/seal-input';
import { useIntl } from '@umijs/max';
import { Form, Modal } from 'antd';
import _ from 'lodash';
import React from 'react';
import SimpleBar from 'simplebar-react';
import 'simplebar-react/dist/simplebar.min.css';
@@ -93,7 +94,32 @@ const UpdateLabels: React.FC<ViewModalProps> = (props) => {
disabled
/>
</Form.Item>
<Form.Item<FormData> name="labels">
<Form.Item<FormData>
name="labels"
rules={[
() => ({
validator(rule, value) {
if (_.keys(value).length > 0) {
if (_.some(_.keys(value), (k: string) => !value[k])) {
return Promise.reject(
intl.formatMessage(
{
id: 'common.validate.value'
},
{
name: intl.formatMessage({
id: 'resources.form.label'
})
}
)
);
}
}
return Promise.resolve();
}
})
]}
>
<LabelSelector
label={intl.formatMessage({
id: 'resources.table.labels'