gitlab.com/evatix-go/core@v1.3.55/regexnew/MatchUsingCustomizeErrorFuncLock.go (about) 1 package regexnew 2 3 // MatchUsingCustomizeErrorFuncLock 4 // 5 // creates new regex using lock 6 // and then calls match. 7 // On condition mismatch returns error 8 // or else nil 9 func MatchUsingCustomizeErrorFuncLock( 10 regexPattern, comparing string, 11 matchFunc RegexValidationFunc, 12 customizeErrFunc CustomizeErr, // can be nil, if nil then use default one 13 ) error { 14 regEx, err := CreateLock(regexPattern) 15 16 if regEx != nil && matchFunc(regEx, comparing) { 17 return nil 18 } 19 20 if customizeErrFunc == nil { 21 return regExMatchValidationError( 22 regexPattern, 23 comparing, 24 err, 25 regEx) 26 } 27 28 return customizeErrFunc( 29 regexPattern, 30 comparing, 31 err, 32 regEx) 33 }