useParitalValid.ts
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* 校验部分字段
*/
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
export default () => {
const validateValueRangeAndStep = (min, step, max) => {
if (min > max) {
createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');
throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';
}
if (step > max - min) {
createMessage.error('步长不能大于取值范围的差值');
throw '步长不能大于取值范围的差值';
}
};
const validateValueBool = (boolClose, boolOpen) => {
if (boolClose == boolOpen) {
createMessage.error('布尔值不能相同');
throw '布尔值不能相同';
}
};
const validateValueStruct = (data: []) => {
if (data.length === 0) {
createMessage.error('struct不能为空');
throw 'struct不能为空';
}
};
return {
validateValueRangeAndStep,
validateValueBool,
validateValueStruct,
};
};