Skip to content

Commit

Permalink
refactor: remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
motss committed Sep 17, 2021
1 parent dc95435 commit 5662c0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/helpers/date-validator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { isValidDate } from './is-valid-date.js';
import { toResolvedDate } from './to-resolved-date.js';
import type { DateValidatorResult, MaybeDate } from './typings.js';

export function dateValidator(value: MaybeDate, defaultDate: Date): DateValidatorResult {
const date = toResolvedDate(value);
const isValid = isValidDate(value, date);
const dateDate = toResolvedDate(value);
const isValid = !(value == null || !(dateDate instanceof Date) || isNaN(+dateDate));

return {
date: isValid ? date : defaultDate,
date: isValid ? dateDate : defaultDate,
isValid,
};
}
3 changes: 0 additions & 3 deletions src/helpers/is-valid-date.ts

This file was deleted.

0 comments on commit 5662c0e

Please sign in to comment.