Skip to content

Commit 70f6eb0

Browse files
committed
uri-template implementation
1 parent 55f5aaa commit 70f6eb0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,10 @@
172172
<version>1.0.5</version>
173173
<scope>test</scope>
174174
</dependency>
175+
<dependency>
176+
<groupId>com.damnhandy</groupId>
177+
<artifactId>handy-uri-templates</artifactId>
178+
<version>2.1.6</version>
179+
</dependency>
175180
</dependencies>
176181
</project>

core/src/main/java/org/everit/json/schema/internal/URITemplateFormatValidator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
package org.everit.json.schema.internal;
22

3+
import static java.lang.String.format;
4+
35
import java.util.Optional;
46

57
import org.everit.json.schema.FormatValidator;
68

9+
import com.damnhandy.uri.template.MalformedUriTemplateException;
10+
import com.damnhandy.uri.template.UriTemplate;
11+
712
public class URITemplateFormatValidator implements FormatValidator {
813

914
@Override public Optional<String> validate(String subject) {
10-
throw new UnsupportedOperationException("not yet implemented");
15+
try {
16+
UriTemplate.fromTemplate(subject);
17+
return Optional.empty();
18+
} catch (MalformedUriTemplateException e) {
19+
return Optional.of(format("[%s] is not a valid URI template", subject));
20+
}
1121
}
1222

1323
@Override public String formatName() {

0 commit comments

Comments
 (0)