Skip to content

Commit

Permalink
Match subsequence instead of entire input sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
mspiegel authored and Michael Spiegel committed Feb 6, 2017
1 parent 98d3fba commit 80a8183
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/PatternValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
if (p != null) {
try {
Matcher m = p.matcher(node.asText());
if (!m.matches()) {
if (!m.find()) {
errors.add(buildValidationMessage(at, pattern));
}
} catch (PatternSyntaxException pse) {
Expand Down
11 changes: 11 additions & 0 deletions src/test/resources/tests/pattern.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@
"valid": true
}
]
},
{
"description": "pattern is not anchored",
"schema": {"pattern": "a+"},
"tests": [
{
"description": "matches a substring",
"data": "xxaayy",
"valid": true
}
]
}
]

0 comments on commit 80a8183

Please sign in to comment.