Skip to content

Commit

Permalink
Add method for checking dob
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtr committed Apr 8, 2024
1 parent 80f34c7 commit db0e90f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public Person toModelType() throws IllegalValueException {
final Ward modelWard = validateAndConvertWard();
final Remark modelRemark = validateAndConvertRemark();

isDobBeforeAdmissionDate(modelDob, modelAdmissionDate);

return new Person(modelName, modelTags, modelDob, modelIc,
modelAdmissionDate, modelWard, modelRemark);
}
Expand Down Expand Up @@ -190,4 +192,10 @@ private Remark validateAndConvertRemark() throws IllegalValueException {
}
return new Remark(remark);
}

private void isDobBeforeAdmissionDate(Dob dob, AdmissionDate admissionDate) throws IllegalValueException {
if (dob.date.isAfter(admissionDate.date)) {
throw new IllegalValueException(Dob.MESSAGE_CONSTRAINTS_OCCURRENCE);
}
}
}

0 comments on commit db0e90f

Please sign in to comment.