Skip to content

Commit

Permalink
fix(fe-piattaforma): fix validazione data servizio massimo 20240807
Browse files Browse the repository at this point in the history
  • Loading branch information
sgravinadxc committed Aug 8, 2024
1 parent c0c6cc3 commit d66b6ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fe-piattaforma/src/utils/csvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const validateFields = (
}
if (record.SE1) {
const parsedDate = new Date(record.SE1);
if(!isValidDateFormat(record.SE1)){
if(!isValidDateFormat(record.SE1) || !isValidDate(record.SE1)){ //valido tramite regex
errors.push("La data inserita per il servizio non e' valida.");
} else if (parsedDate > maxDate) {
errors.push("La data del servizio e' successiva al 30 Giugno 2024.");
Expand Down Expand Up @@ -178,6 +178,11 @@ function isValidDateFormat(dateString : string) {
return regex.test(dateString);
}

function isValidDate(dateString : string) {
let parsedDate = moment(dateString);
return parsedDate.isValid()
}

export function containsOnlyNumber(value: string): boolean {
return value >= '0' && value <= '9';
}
Expand Down

0 comments on commit d66b6ab

Please sign in to comment.