]> Sergey Matveev's repositories - path-extractor.git/blob - validators.go
Update readme for binding with bash
[path-extractor.git] / validators.go
1 package main
2
3 import "strings"
4 import "regexp"
5
6 func isGitRange (input string) bool {
7     r := regexp.MustCompile("[0-9a-f]{3,}\\.\\.[0-9a-f]{3,}")
8     return r.Match([]byte(input))
9 }
10
11 func isGitPath (input string) bool {
12     r := regexp.MustCompile("^[ab]/")
13     return r.Match([]byte(input))
14 }
15
16 func isDate (input string) bool {
17     r := regexp.MustCompile("^[0-9]+/[0-9]+/[0-9]+")
18     return r.Match([]byte(input))
19 }
20
21 func isGitInstruction (input string) bool {
22     r := regexp.MustCompile("\\.{3,}")
23     return r.Match([]byte(input))
24 }
25
26 func replaceGitPath (input string) string {
27     r := regexp.MustCompile("^[ab]/(.*)")
28     temp := [][]byte{}
29     temp = r.FindSubmatch([]byte(input))
30     return string(temp[1])
31 }
32
33 func isVersion (input string) bool {
34     r := regexp.MustCompile("[0-9x]\\.[0-9x]{1,2}(\\.[0-9x]{1,3})?")
35     return r.Match([]byte(input))
36 }
37
38 func containsInvalidString (input string) bool {
39     invalidStrings := []string{"(",")","@","origin/","{","}","<",">","$","*"}
40     for _,s := range invalidStrings {
41         if strings.Contains(input,s) {
42             return true
43         }
44     }
45     return false
46 }