useValidateParital.ts 961 Bytes
/**
 * 校验部分字段
 */
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();

export const validateValueRangeAndStep = (min, step, max) => {
  if (min > max) {
    createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');
    throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';
  }
  if (step > max - min) {
    createMessage.error('步长不能大于取值范围的差值');
    throw '步长不能大于取值范围的差值';
  }
};

export const validateValueBool = (boolClose, boolOpen) => {
  if (boolClose == boolOpen) {
    createMessage.error('布尔值不能相同');
    throw '布尔值不能相同';
  }
};

export const validateValueStruct = (data: []) => {
  if (data.length === 0) {
    createMessage.error('struct不能为空');
    throw 'struct不能为空';
  }
};