added pin.go to contain all PIN related functionality
This commit is contained in:
14
common/pin.go
Normal file
14
common/pin.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package common
|
||||
|
||||
import "regexp"
|
||||
|
||||
// Define the regex pattern as a constant
|
||||
const (
|
||||
pinPattern = `^\d{4}$`
|
||||
)
|
||||
|
||||
// checks whether the given input is a 4 digit number
|
||||
func IsValidPIN(pin string) bool {
|
||||
match, _ := regexp.MatchString(pinPattern, pin)
|
||||
return match
|
||||
}
|
||||
Reference in New Issue
Block a user