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