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

Fix V631 Validation for Invalid Value in Co-Applicant Ethnicity #4832

Merged
merged 17 commits into from
Jul 10, 2024
Merged
3 changes: 3 additions & 0 deletions hmda/src/main/scala/hmda/validation/dsl/PredicateCommon.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hmda.validation.dsl

import hmda.model.filing.lar.enums.EthnicityEnum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this import so it's no longer needed


import scala.util.Try

object PredicateCommon {
Expand Down Expand Up @@ -64,6 +66,7 @@ object PredicateCommon {

def empty[A]: Predicate[A] = (_: A) match {
case s: String => s.isEmpty
case s: EthnicityEnum => s.code == 0
jaredb96 marked this conversation as resolved.
Show resolved Hide resolved
jaredb96 marked this conversation as resolved.
Show resolved Hide resolved
case _ =>
throw new NotImplementedError("'empty doesn't handle non-string values yet'")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import hmda.model.filing.lar.LoanApplicationRegister
import hmda.model.filing.lar.enums._
import hmda.validation.dsl.PredicateCommon._
import hmda.validation.dsl.PredicateSyntax._
import hmda.validation.dsl.ValidationResult
import hmda.validation.dsl.{ValidationResult, ValidationSuccess, ValidationFailure}
import hmda.validation.rules.EditCheck

object V631_1 extends EditCheck[LoanApplicationRegister] {
Expand All @@ -25,7 +25,10 @@ object V631_1 extends EditCheck[LoanApplicationRegister] {
)

override def apply(lar: LoanApplicationRegister): ValidationResult =
when(lar.coApplicant.ethnicity.otherHispanicOrLatino is empty) {
lar.coApplicant.ethnicity.ethnicity1 is containedIn(validEthnicities)
if(lar.coApplicant.ethnicity.otherHispanicOrLatino.isEmpty) {
Copy link
Contributor Author

@jaredb96 jaredb96 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is replicating the when block in the previous logic using a the ethnicity string. This if implements the rules listed here.

lar.coApplicant.ethnicity.ethnicity1 is containedIn(validEthnicities) and (lar.coApplicant.ethnicity.ethnicity1 not empty)
}
else {
lar.coApplicant.ethnicity.ethnicity1 is containedIn(validEthnicities) or (lar.coApplicant.ethnicity.ethnicity1 is empty)
}
}
Loading