Skip to content

Commit

Permalink
fix: validate date string before converting to LocalDate (#6880) (#6883)
Browse files Browse the repository at this point in the history
* fix: validate date string before converting

* docs: update CHANGELOG
  • Loading branch information
Zangetsu101 committed Apr 30, 2024
1 parent 226d6f5 commit 29436e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [1.3.5](https://github.com/opencrvs/opencrvs-core/compare/v1.3.4...v1.3.5)

## Bug fixes
- #### Fix download failure for incomplete (without date of death) death declarations [#6807](https://github.com/opencrvs/opencrvs-core/issues/6807)

## [1.3.4](https://github.com/opencrvs/opencrvs-core/compare/v1.3.3...v1.3.4)

## Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { IFormField, IFormData } from '@client/forms'
import { formatPlainDate } from '@client/utils/date-formatting'
import {
formatPlainDate,
isValidPlainDate
} from '@client/utils/date-formatting'

export const deceasedDateToFieldTransformation =
(alternativeSectionId?: string) =>
Expand Down Expand Up @@ -46,8 +49,7 @@ export const deceasedDateFormatTransformation =
}
const queryValue = queryData[fromSectionId].deceased.deathDate

const date = new Date(queryValue)
if (!Number.isNaN(date.getTime())) {
if (isValidPlainDate(queryValue)) {
const prevLocale = window.__localeId__
window.__localeId__ = locale

Expand Down

0 comments on commit 29436e1

Please sign in to comment.