import { FormRules } from "element-plus";
import { isArray, isMobile, isChinese, isEmoticon } from "/@/utils/validate";
export const projectFormRules: FormRules = {
  starttime: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请选择有效开始日期");
      return true;
    }
  },
  expiretime: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请选择有效结束日期");
      return true;
    }
  },

  name: {
    trigger: "change",
    required: true,
    validator(_, value) {
      if (value === "") return new Error("请输入姓名！");
      if (!isChinese(value)) return new Error("姓名必须为汉字！");
      if (isEmoticon(value)) return new Error("姓名必须为汉字！");
      return true;
    }
  },
  mobile: {
    trigger: "change",
    required: true,
    validator(_, value) {
      if (!value || !isMobile(value)) return new Error("手机号不规范！");
      return true;
    }
  },
  video_ids: {
    trigger: "change",
    required: true,
    validator(_, value) {
      console.log(value);
      if (!isArray(value)) return new Error("请选择直播视频");
      const length = value.length;
      if (length === 0) return new Error("请选择直播视频");
      return true;
    }
  }
};
