Skip to content

Commit

Permalink
Fix issue with limited postal code input
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Oct 17, 2022
1 parent 30b9be6 commit e21d20b
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ internal class PostalCodeConfig(
}

override fun getError(): FieldError? {
return when {
input.isNotBlank() && !isFull() && country == "US" -> {
FieldError(R.string.address_zip_invalid)
}
input.isNotBlank() && !isFull() -> {
FieldError(R.string.address_zip_postal_invalid)
}
else -> null
return if (!isValid()) {
FieldError(
errorMessage = if (country == "US") {
R.string.address_zip_invalid
} else {
R.string.address_zip_postal_invalid
}
)
} else {
null
}
}

override fun isFull(): Boolean = input.length >= format.minimumLength
override fun isFull(): Boolean = input.length >= format.maximumLength

override fun isBlank(): Boolean = input.isBlank()
}
Expand Down

0 comments on commit e21d20b

Please sign in to comment.