Skip to content

Commit

Permalink
dateTimeValidator changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OgunyemiO committed Aug 20, 2024
1 parent 32dd9cf commit 00f87b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/noc/containers/noc-field/utils/noc-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export class NocValidators {
return null;
}
const value = control.value.toString();
console.log(value)
const [year, month, day] = value.split('-').map(Number);
const isValidDate = moment(value, 'YYYY-MM-DD', true).isValid();
if (!isValidDate || year === 0 || month === 0 || month > 12 || day === 0 || day > 31) {
return { month: true, date: true, valid: false };
return { date: true, month: true, year: true, valid: false };
}
return null;
};
Expand Down

0 comments on commit 00f87b1

Please sign in to comment.