diff --git a/utils/index.d.ts b/utils/index.d.ts index a089e62..2238b1f 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -333,6 +333,13 @@ export function validatorEndTime(timeStart: string): { validator: (_: any, value: any) => Promise; }; +/** + * 验证结束时间是否大于等于当前时间 + */ +export function validatorEndTimeGTCurrentDay(): { + validator: (_: any, value: any) => Promise; +}; + /** * 动态加载js资源 */ diff --git a/utils/index.js b/utils/index.js index 4ddf17a..249b47f 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,4 +1,5 @@ import { ID_NUMBER } from "../regular"; +import dayjs from "dayjs"; /** * 计算序号 @@ -523,6 +524,22 @@ export const validatorEndTime = (timeStart) => { } } +/** + * 验证结束时间是否大于等于当前时间 + */ +export const validatorEndTimeGTCurrentDay = () => { + return { + validator: (_, value) => { + if (value && value <= dayjs().format("YYYY-MM-DD hh:mm:ss")) { + return Promise.reject("结束时间必须大于当前时间"); + } + else { + return Promise.resolve(); + } + }, + } +} + /** * 动态加载js资源 */