diff --git a/format_checkers.go b/format_checkers.go
index b91c360..4d5c4f2 100644
--- a/format_checkers.go
+++ b/format_checkers.go
@@ -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 (
@@ -74,6 +77,7 @@ var (
"ipv6": IPV6FormatChecker{},
"uri": URIFormatChecker{},
"uuid": UUIDFormatChecker{},
+ "regex": RegexFormatChecker{},
},
}
@@ -176,3 +180,8 @@ func (f HostnameFormatChecker) IsFormat(input string) bool {
func (f UUIDFormatChecker) IsFormat(input string) bool {
return rxUUID.MatchString(input)
}
+
+func (f RegexFormatChecker) IsFormat(input string) bool {
+ reg, _ := regexp.Compile(input)
+ return reg != nil
+}
The schema at http://json-schema.org/schema# can not be validated using the tool because it contains an invalid "regex" format for the "pattern" definition.
I suggest to patch the formatchecker to include regex as a valid format until the "official" schema is fixed.