Skip to content

Parent's DOB does not validate against the child's DOB if it occurred at least 10 years ago. #11194

@prinzab

Description

@prinzab

Describe the bug
The age-difference validator on the Birth Declaration Form is incorrectly comparing the parents’ dates of birth (DOB) to today’s date instead of comparing them to the child’s date of birth.

As a result, if the child’s DOB and the parent’s DOB are both more than 10 years in the past from today, the system fails to validate whether the parent is at least 10 years older than the child.

Which feature of OpenCRVS your bug concern?
This bug has to do with the Declaration form

To Reproduce
Steps to reproduce the behaviour:

  1. Login as a user who can start a declaration
  2. Choose birth
  3. On the child's details page, enter "01/01/2015" as the DOB
  4. On the mother's details page, enter "01/01/2015" as the DOB
  5. On the father's details page, enter "01/01/2015" as the DOB
  6. Observe that the system DOES NOT show an error informing the user that Mother/Father must be at least 10 years older than the child the

Expected behaviour

  • The parent’s date of birth must always be at least 10 years earlier than the child’s date of birth.
  • The validator should compare parent DOB vs. child DOB, not parent DOB vs. today.
  • If the parent’s DOB is less than 10 years earlier than the child’s DOB (or the same date), the system should display an error message, e.g.: Mother/Father “must be at least 10 years older than the child.”

Actual behaviour
The system does not show any validation error when the mother’s or father’s DOB is the same as the child’s DOB (e.g., both 01/01/2015), as long as both dates are at least 10 years before today.

This results in an incorrect scenario where the parents and the child can be treated as the same age, which is impossible.

Country Configuration Version:

Link to discussion:
#11123

Technical approach

field('mother.dob').isBefore().days(3650).field('child.dob')
field('child.dob').isAfter().days(3650).field('mother.dob')

Introduce a new method .field(FieldReference) that can be used instead of .inPast() and inFuture(). Write sufficient unit tests so its functionality can be tested even beyond these cases.

Metadata

Metadata

Labels

IET requestissues that came up from IET triage

Type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions