Skip to content

Commit

Permalink
refactor: minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
motss committed Sep 17, 2021
1 parent 5662c0e commit e02e768
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helpers/date-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { DateValidatorResult, MaybeDate } from './typings.js';

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

return {
date: isValid ? dateDate : defaultDate,
isValid,
date: isInvalid ? defaultDate : dateDate,
isValid: !isInvalid,
};
}

0 comments on commit e02e768

Please sign in to comment.