...
|
...
|
@@ -2,10 +2,13 @@ import { ValidatorRule } from 'ant-design-vue/lib/form/interface'; |
2
|
2
|
import { i18n } from '/@/locales/setupI18n';
|
3
|
3
|
export { default as ThingsModelForm } from './index.vue';
|
4
|
4
|
|
5
|
|
-export const validateTCPCustomCommand: ValidatorRule['validator'] = (_rule, value) => {
|
|
5
|
+export const validateTCPCustomCommand: ValidatorRule['validator'] = (_rule, value = '') => {
|
6
|
6
|
const reg = /^[\s0-9a-fA-F]+$/;
|
7
|
|
- if (reg.test(value)) return Promise.resolve();
|
8
|
|
- return Promise.reject(i18n.global.t('validator.hex'));
|
|
7
|
+ if (!reg.test(value)) return Promise.reject(i18n.global.t('validator.hex'));
|
|
8
|
+
|
|
9
|
+ if (value?.length % 2) return Promise.reject(i18n.global.t('validator.hexLength'));
|
|
10
|
+
|
|
11
|
+ return Promise.resolve();
|
9
|
12
|
};
|
10
|
13
|
|
11
|
14
|
export const trimBlankSpace = (string: string) => string.replace(/(?!^)(?=(\w{2})+$)/g, '');
|
...
|
...
|
|