|
1 | 1 | package org.everit.json.schema;
|
2 | 2 |
|
3 |
| -import static java.lang.String.format; |
4 | 3 | import static java.util.Objects.requireNonNull;
|
5 | 4 | import static org.everit.json.schema.FormatValidator.NONE;
|
6 | 5 |
|
7 |
| -import java.util.Arrays; |
8 |
| -import java.util.List; |
9 | 6 | import java.util.Objects;
|
10 | 7 | import java.util.regex.Pattern;
|
11 | 8 |
|
@@ -121,53 +118,10 @@ public Pattern getPattern() {
|
121 | 118 | return pattern;
|
122 | 119 | }
|
123 | 120 |
|
124 |
| - private void testLength(final String subject, List<ValidationException> validationExceptions) { |
125 |
| - int actualLength = subject.codePointCount(0, subject.length()); |
126 |
| - if (minLength != null && actualLength < minLength.intValue()) { |
127 |
| - validationExceptions.add( |
128 |
| - failure("expected minLength: " + minLength + ", actual: " |
129 |
| - + actualLength, "minLength")); |
130 |
| - } |
131 |
| - if (maxLength != null && actualLength > maxLength.intValue()) { |
132 |
| - validationExceptions.add( |
133 |
| - failure("expected maxLength: " + maxLength + ", actual: " |
134 |
| - + actualLength, "maxLength")); |
135 |
| - } |
136 |
| - } |
137 |
| - |
138 |
| - private void testPattern(final String subject, List<ValidationException> validationExceptions) { |
139 |
| - if (pattern != null && !pattern.matcher(subject).find()) { |
140 |
| - String message = format("string [%s] does not match pattern %s", |
141 |
| - subject, pattern.pattern()); |
142 |
| - validationExceptions.addAll(Arrays.asList(failure(message, "pattern"))); |
143 |
| - } |
144 |
| - } |
145 |
| - |
146 | 121 | @Override void accept(Visitor visitor) {
|
147 | 122 | visitor.visitStringSchema(this);
|
148 | 123 | }
|
149 | 124 |
|
150 |
| - // @Override |
151 |
| - // public void validate(final Object subject) { |
152 |
| - // if (!(subject instanceof String)) { |
153 |
| - // if (requiresString) { |
154 |
| - // throw failure(String.class, subject); |
155 |
| - // } |
156 |
| - // } else { |
157 |
| - // List<ValidationException> validationExceptions = new ArrayList<>(); |
158 |
| - // String stringSubject = (String) subject; |
159 |
| - // testLength(stringSubject, validationExceptions); |
160 |
| - // testPattern(stringSubject, validationExceptions); |
161 |
| - // Optional<String> failure = formatValidator.validate(stringSubject); |
162 |
| - // if (failure.isPresent()) { |
163 |
| - // validationExceptions.add(failure(failure.get(), "format")); |
164 |
| - // } |
165 |
| - // if (null != validationExceptions) { |
166 |
| - // ValidationException.throwFor(this, validationExceptions); |
167 |
| - // } |
168 |
| - // } |
169 |
| - // } |
170 |
| - |
171 | 125 | @Override
|
172 | 126 | public boolean equals(Object o) {
|
173 | 127 | if (this == o)
|
|
0 commit comments