public class PatternFacet extends Object implements Facet<JsonString>
This facet is applicable to string()
type only.
If the value of the type does not match the specified regular expression,
StringPatternProblem
will be reported by this facet.
Important note is that the pattern specified for this facet must be compatible with Java regular expression and not with JavaScript alternative defined in the ECMA 262 specification.
Constructor and Description |
---|
PatternFacet(String regex)
Constructs this facet.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(JsonString value,
List<Problem> problems)
Applies this facet to a value in JSON document and
when the value is out of valid value space, it reports one or more corresponding problems.
|
public PatternFacet(String regex)
regex
- the regular expression which strictly conforms to Java specification
accurately described in Pattern
class.PatternSyntaxException
- If the expression's syntax is invalid.Pattern
public void apply(JsonString value, List<Problem> problems)
Facet
apply
in interface Facet<JsonString>
value
- JsonValue
in JSON document to be validated.problems
- the list of problems to which new problems found by this facet will be added.Copyright © 2016–2017. All rights reserved.