Skip to content

Commit

Permalink
RegexFormatChecker, gofmt -s -w
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkowalczuk committed Jun 23, 2016
1 parent c395321 commit c7df3b5
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 281 deletions.
16 changes: 16 additions & 0 deletions format_checkers.go
Expand Up @@ -60,6 +60,9 @@ type (

// UUIDFormatChecker validates a UUID is in the correct format
UUIDFormatChecker struct{}

// RegexFormatChecker validates a regex is in the correct format
RegexFormatChecker struct{}
)

var (
Expand All @@ -74,6 +77,7 @@ var (
"ipv6": IPV6FormatChecker{},
"uri": URIFormatChecker{},
"uuid": UUIDFormatChecker{},
"regex": UUIDFormatChecker{},
},
}

Expand Down Expand Up @@ -176,3 +180,15 @@ func (f HostnameFormatChecker) IsFormat(input string) bool {
func (f UUIDFormatChecker) IsFormat(input string) bool {
return rxUUID.MatchString(input)
}

// IsFormat implements FormatChecker interface.
func (f RegexFormatChecker) IsFormat(input string) bool {
if input == "" {
return true
}
_, err := regexp.Compile(input)
if err != nil {
return false
}
return true
}
2 changes: 0 additions & 2 deletions jsonLoader.go
Expand Up @@ -77,7 +77,6 @@ func (f FileSystemJSONLoaderFactory) New(source string) JSONLoader {
}
}


// osFileSystem is a functional wrapper for os.Open that implements http.FileSystem.
type osFileSystem func(string) (*os.File, error)

Expand Down Expand Up @@ -166,7 +165,6 @@ func (l *jsonReferenceLoader) LoadJSON() (interface{}, error) {

}


func (l *jsonReferenceLoader) loadFromHTTP(address string) (interface{}, error) {

resp, err := http.Get(address)
Expand Down

0 comments on commit c7df3b5

Please sign in to comment.