Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added future DOB validation #648

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go-app-ussd_clinic_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,11 @@ go.app = function() {
"Enter the day that baby was born as a number. For example if baby was born on 12th May, type in 12"
].join("\n"));
}
if (date > current_date){
return $(
"Sorry, that date is in the future. Please enter a valid date."
);
}
if (!date.isBetween(current_date.clone().add(-2, "years"), current_date.add(1, "days")) ) {
return $(
"Unfortunately MomConnect doesn't send messages to children older " +
Expand Down
5 changes: 5 additions & 0 deletions src/ussd_clinic_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ go.app = function() {
"Enter the day that baby was born as a number. For example if baby was born on 12th May, type in 12"
].join("\n"));
}
if (date > current_date){
return $(
"Sorry, that date is in the future. Please enter a valid date."
);
}
if (!date.isBetween(current_date.clone().add(-2, "years"), current_date.add(1, "days")) ) {
return $(
"Unfortunately MomConnect doesn't send messages to children older " +
Expand Down
11 changes: 11 additions & 0 deletions test/ussd_clinic_rapidpro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,17 @@ describe("ussd_clinic app", function() {
})
.run();
});
it("should return an error if the date of birth is in the future", function() {
return tester
.setup.user.state("state_birth_day")
.setup.user.answer("state_birth_month","2020-04")
.input("1")
.check.interaction({
reply:
"Sorry, that date is in the future. Please enter a valid date."
})
.run();
});
it("should pass if the date of birth is today", function() {
return tester
.setup.user.state("state_birth_day")
Expand Down
Loading