Skip to content

Commit

Permalink
feat(jsonschema format): added iri, iri-ref, regex format validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Osterbind committed Jan 23, 2018
1 parent 8f42c9f commit 4e5183a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions keywords_format.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions schema_test.go
Expand Up @@ -260,7 +260,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",
Expand All @@ -271,8 +271,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",
})
}
Expand Down

0 comments on commit 4e5183a

Please sign in to comment.