Compare commits

..

1 Commits

1 changed files with 5 additions and 4 deletions

View File

@ -62,8 +62,8 @@ export default defineComponent({
setup(props, { emit, attrs }) {
const customRules = computed(() => [
props.type == 'date' ? stringIsDate : props.type == 'time' ? stringIsTime : stringIsDateTime,
(value?: string | null) => {
if (props.rules.length > 0 && value) {
(value?: string) => {
if (props.rules.length > 0 && !!value) {
let date: Date | undefined = undefined;
if (props.type == 'date') date = modifyDate(value);
else if (props.type == 'time') date = modifyTime(value);
@ -71,10 +71,11 @@ export default defineComponent({
const split = value.split(' ');
date = modifyTime(split[1], modifyDate(split[0]));
}
props.rules.forEach((rule) => {
for (const rule of props.rules) {
const r = rule(date);
if (typeof r === 'string') return r;
});
}
return true;
}
},
]);