<commit_before>package hmda.validation.rules.lar.validity

import hmda.model.fi.lar.{ Loan, LoanApplicationRegister }
import hmda.validation.dsl.{ Failure, Success }
import hmda.validation.rules.lar.LarEditCheckSpec
import org.scalacheck.Gen

class V330Spec extends LarEditCheckSpec {
  property("Income must be greater than 0 or 'NA'") {
    forAll(larGen) { lar =>
      V330(lar) mustBe Success()
    }
  }

  val badIncomeNumberGen: Gen[Int] = Gen.choose(Integer.MIN_VALUE, 0)

  property("Income less than or equal to 0 is invalid") {
    forAll(larGen, badIncomeNumberGen) { (lar: LoanApplicationRegister, x: Int) =>
      val invalidApplicant = lar.applicant.copy(income = x.toString)
      val invalidLar = lar.copy(applicant = invalidApplicant)
      V330(invalidLar) mustBe a[Failure]
    }
  }

  val badIncomeStringGen: Gen[String] = Gen.alphaStr suchThat (_ != "NA")

  property("Any string aside from NA is invalid") {
    forAll(larGen, badIncomeStringGen) { (lar: LoanApplicationRegister, x: String) =>
      val invalidApplicant = lar.applicant.copy(income = x)
      val invalidLar = lar.copy(applicant = invalidApplicant)
      V330(invalidLar) mustBe a[Failure]
    }
  }
}<commit_msg>Add check method to V330Spec<commit_after>package hmda.validation.rules.lar.validity

import hmda.model.fi.lar.{ Loan, LoanApplicationRegister }
import hmda.validation.dsl.{ Failure, Success }
import hmda.validation.rules.EditCheck
import hmda.validation.rules.lar.LarEditCheckSpec
import org.scalacheck.Gen

class V330Spec extends LarEditCheckSpec {
  property("Income must be greater than 0 or 'NA'") {
    forAll(larGen) { lar =>
      V330(lar) mustBe Success()
    }
  }

  val badIncomeNumberGen: Gen[Int] = Gen.choose(Integer.MIN_VALUE, 0)

  property("Income less than or equal to 0 is invalid") {
    forAll(larGen, badIncomeNumberGen) { (lar: LoanApplicationRegister, x: Int) =>
      val invalidApplicant = lar.applicant.copy(income = x.toString)
      val invalidLar = lar.copy(applicant = invalidApplicant)
      V330(invalidLar) mustBe a[Failure]
    }
  }

  val badIncomeStringGen: Gen[String] = Gen.alphaStr suchThat (_ != "NA")

  property("Any string aside from NA is invalid") {
    forAll(larGen, badIncomeStringGen) { (lar: LoanApplicationRegister, x: String) =>
      val invalidApplicant = lar.applicant.copy(income = x)
      val invalidLar = lar.copy(applicant = invalidApplicant)
      V330(invalidLar) mustBe a[Failure]
    }
  }

  override def check: EditCheck[LoanApplicationRegister] = V330
}
{'fraction_non_alphanumeric': 0.10794780545670225, 'fraction_numerical': 0.014234875444839857, 'mean_word_length': 4.1318458417849895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629616', 'n_tokens_mistral': 897, 'n_tokens_neox': 816, 'n_words': 195}