Skip to content

Commit

Permalink
Fix issue with limited postal code input (#5715)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe authored Oct 17, 2022
1 parent aa18ea8 commit d1eeeaa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Payments

* [FIXED][5701](https://github.com/stripe/stripe-android/pull/5701) Treat blank fields as invalid in `ShippingInfoWidget`.
* [FIXED][5715](https://github.com/stripe/stripe-android/pull/5715) Postal codes for countries other than US and Canada are no longer limited to a single character.

## 20.15.0 - 2022-10-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ internal class PostalCodeConfig(

override fun getError(): FieldError? {
return when {
input.isNotBlank() && !isFull() && country == "US" -> {
input.isNotBlank() && !isValid() && country == "US" -> {
FieldError(R.string.address_zip_invalid)
}
input.isNotBlank() && !isFull() -> {
input.isNotBlank() && !isValid() -> {
FieldError(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
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class PostalCodeConfigTest {
Truth.assertThat(determineStateForInput(" ").isValid()).isFalse()
Truth.assertThat(determineStateForInput(" ").isFull()).isFalse()
Truth.assertThat(determineStateForInput("a").isValid()).isTrue()
Truth.assertThat(determineStateForInput("a").isFull()).isTrue()
Truth.assertThat(determineStateForInput("a").isFull()).isFalse()
Truth.assertThat(determineStateForInput("1").isValid()).isTrue()
Truth.assertThat(determineStateForInput("1").isFull()).isTrue()
Truth.assertThat(determineStateForInput("1").isFull()).isFalse()
Truth.assertThat(determineStateForInput("aaaaaa").isValid()).isTrue()
Truth.assertThat(determineStateForInput("111111").isValid()).isTrue()
}
Expand Down

0 comments on commit d1eeeaa

Please sign in to comment.