added pin.go to contain all PIN related functionality

This commit is contained in:
2025-01-02 13:16:38 +03:00
parent ed1aeecf7d
commit 48d63fb43f
3 changed files with 18 additions and 16 deletions

14
common/pin.go Normal file
View 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
}