diff --git a/keywords_format.go b/keywords_format.go index 94d5b7b..ff8a6f9 100644 --- a/keywords_format.go +++ b/keywords_format.go @@ -199,14 +199,14 @@ func isValidIPv6(ipv6 string) error { // according to [RFC3987]. // https://tools.ietf.org/html/rfc3987 func isValidIriRef(iriRef string) error { - return nil + return isValidURIRef(iriRef) } // A string instance is a valid against "iri" if it is a valid IRI, // according to [RFC3987]. // https://tools.ietf.org/html/rfc3987 func isValidIri(iri string) error { - return nil + return isValidURI(iri) } // A string instance is a valid against "json-pointer" if it is a @@ -240,6 +240,9 @@ func isValidJSONPointer(jsonPointer string) error { // http://json-schema.org/latest/json-schema-validation.html#regexInterop // https://tools.ietf.org/html/rfc7159 func isValidRegex(regex string) error { + if _, err := regexp.Compile(regex); err != nil { + return fmt.Errorf("invalid regex expression") + } return nil } diff --git a/schema_test.go b/schema_test.go index f0386d8..02287bc 100644 --- a/schema_test.go +++ b/schema_test.go @@ -286,7 +286,7 @@ func TestDraft7(t *testing.T) { "testdata/draft7/optional/format/date-time.json", "testdata/draft7/optional/format/hostname.json", "testdata/draft7/optional/format/ipv4.json", - // "testdata/draft7/optional/format/iri.json", + "testdata/draft7/optional/format/iri.json", "testdata/draft7/optional/format/relative-json-pointer.json", "testdata/draft7/optional/format/uri-template.json", "testdata/draft7/optional/format/date.json", @@ -297,8 +297,8 @@ func TestDraft7(t *testing.T) { "testdata/draft7/optional/format/uri.json", "testdata/draft7/optional/format/email.json", "testdata/draft7/optional/format/idn-hostname.json", - // "testdata/draft7/optional/format/iri-reference.json", - // "testdata/draft7/optional/format/regex.json", + "testdata/draft7/optional/format/iri-reference.json", + "testdata/draft7/optional/format/regex.json", "testdata/draft7/optional/format/uri-reference.json", }) }