|
1
|
|
|
//package hkid to check HKID Card No. |
|
2
|
|
|
package hkid |
|
3
|
|
|
|
|
4
|
|
|
// CheckString : Check HKID Format eg. CA182361(1). |
|
5
|
|
|
func CheckString(string string) *result { |
|
6
|
1 |
|
hkid, e := validatePatten(string) |
|
7
|
|
|
//if errors.Is(e, newPatterNotMatchError()) { |
|
8
|
1 |
|
if e != nil { |
|
9
|
1 |
|
return newHkidResultWithValid(newHkidNil(), false) |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
1 |
|
if getRemainder(hkid) == hkid.part3 { |
|
13
|
1 |
|
return newHkidResultWithValid(hkid, true) |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
1 |
|
return newHkidResultWithValid(hkid, false) |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
// CheckPart : check HKID Format eg. CA182361(1). |
|
20
|
|
|
// part1 = "CA" |
|
21
|
|
|
// part2 = "182361" |
|
22
|
|
|
// part3 = "1" |
|
23
|
|
|
func CheckPart(part1 string, part2 string, part3 string) *result { |
|
24
|
1 |
|
hkid := newHkid(part1, part2, part3) |
|
25
|
1 |
|
return CheckString(hkid.Format()) |
|
26
|
|
|
} |
|
27
|
|
|
|