-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 계좌번호 입력 유효성 기능 추가 * feat: 계좌번호 유효성을 검증하고 input을 컨트롤하는 기능 추가 * style: console.log 제거 * feat: 계좌번호 정규표현식 수정 --------- Co-authored-by: Soyeon Choe <[email protected]>
- Loading branch information
1 parent
dff7f4f
commit 19b91a5
Showing
6 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {ERROR_MESSAGE} from '@constants/errorMessage'; | ||
import REGEXP from '@constants/regExp'; | ||
import RULE from '@constants/rule'; | ||
|
||
import {ValidateResult} from './type'; | ||
|
||
const validateAccountNumber = (accountNumber: string): ValidateResult => { | ||
const isValidateType = () => { | ||
return REGEXP.accountNumber.test(accountNumber); | ||
}; | ||
|
||
const isValidateLength = () => { | ||
return accountNumber.length >= RULE.minAccountNumberLength && accountNumber.length <= RULE.maxAccountNumberLength; | ||
}; | ||
|
||
if (isValidateType() && isValidateLength()) { | ||
return {isValid: true, errorMessage: null}; | ||
} | ||
|
||
return {isValid: false, errorMessage: ERROR_MESSAGE.invalidAccountNumber}; | ||
}; | ||
|
||
export default validateAccountNumber; |