Skip to content

Commit

Permalink
fix: card validation focus check (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
aritro2002 authored Dec 9, 2024
1 parent c49f278 commit fd15e54
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,12 @@ let swapCardOption = (cardOpts: array<string>, dropOpts: array<string>, selected

let setCardValid = (cardnumber, setIsCardValid) => {
let cardBrand = getCardBrand(cardnumber)
let isCardMaxLength = cardnumber->String.length == maxCardLength(cardBrand)
if cardValid(cardnumber, cardBrand) {
setIsCardValid(_ => Some(true))
} else if (
!cardValid(cardnumber, cardBrand) && isCardLengthValid(cardBrand, cardnumber->String.length)
) {
} else if !cardValid(cardnumber, cardBrand) && isCardMaxLength {
setIsCardValid(_ => Some(false))
} else if !isCardLengthValid(cardBrand, cardnumber->String.length) {
} else if !isCardMaxLength {
setIsCardValid(_ => None)
}
}
Expand Down

0 comments on commit fd15e54

Please sign in to comment.