验证
返回 boolean 指示 Dayjs 的日期是否有效。
¥Returns a boolean indicating whether the Dayjs's date is valid.
不严格检查。
¥Non-strict check.
仅检查该值是否可以解析为日期时间。
¥Only checks if the value could be parsed to a Date time.
dayjs('2022-01-33').isValid(); // true, parsed to 2022-02-02 dayjs('some invalid string').isValid(); // false严格检查。
¥Strict check.
检查该值是否可以解析为日期时间并且它是有效日期。必须提供最后两个参数
format和strict。This requires the
CustomParseFormatplugin to work¥Checks if the value could be parsed to a Date time and it is a valid date. The last two arguments
formatandstrictmust be provided.This requires the
CustomParseFormatplugin to workdayjs('2022-02-31', 'YYYY-MM-DD', true).isValid(); // false
