Skip to content

Commit 1607832

Browse files
authored
Merge pull request #15 from SentryMan/core
removed required
2 parents 30ba6e0 + 59d0ecb commit 1607832

File tree

6 files changed

+10
-67
lines changed

6 files changed

+10
-67
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
package io.avaje.validation.adapter;
22

3-
public interface CoreValidation {
4-
5-
/** Return true to continue validation on this value if needed */
6-
boolean required(Object value, ValidationRequest ctx, String propertyName);
7-
}
3+
public interface CoreValidation {}

validator/src/main/java/io/avaje/validation/adapter/ValidationAdapter.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
/*
2-
* Copyright (C) 2014 Square, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package io.avaje.validation.adapter;
172

18-
import io.avaje.validation.Validator;
19-
203
import java.lang.reflect.Type;
214
import java.util.Collection;
225
import java.util.Objects;
236

7+
import io.avaje.validation.Validator;
8+
249
public interface ValidationAdapter<T> {
2510

2611
/** Return true if validation should recurse */
@@ -35,8 +20,9 @@ default boolean validateAll(Collection<T> value, ValidationRequest req, String p
3520
req.pushPath(propertName);
3621
}
3722
int index = -1;
38-
for (T element : value) {
39-
validate(element, req, String.valueOf(++index));
23+
for (final T element : value) {
24+
index++;
25+
validate(element, req, String.valueOf(index));
4026
}
4127
if (propertName != null) {
4228
req.popPath();
@@ -49,8 +35,9 @@ default boolean validateAll(T[] value, ValidationRequest req, String propertName
4935
req.pushPath(propertName);
5036
}
5137
int index = -1;
52-
for (T element : value) {
53-
validate(element, req, String.valueOf(++index));
38+
for (final T element : value) {
39+
index++;
40+
validate(element, req, String.valueOf(index));
5441
}
5542
if (propertName != null) {
5643
req.popPath();

validator/src/main/java/io/avaje/validation/core/CoreAdapterBuilder.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
* Copyright (C) 2014 Square, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package io.avaje.validation.core;
172

183
import java.lang.annotation.Annotation;
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
package io.avaje.validation.core;
22

33
import io.avaje.validation.adapter.CoreValidation;
4-
import io.avaje.validation.adapter.ValidationRequest;
54

65
final class DCoreValidation implements CoreValidation {
76

8-
@Override
9-
public boolean required(Object value, ValidationRequest ctx, String propertyName) {
10-
if (value == null) {
11-
ctx.addViolation("Required", propertyName);
12-
return false;
13-
}
14-
return true;
15-
}
7+
168
}

validator/src/main/java/io/avaje/validation/core/JakartaTypeAdapters.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
* Copyright (C) 2014 Square, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package io.avaje.validation.core;
172

183
import java.lang.reflect.Array;

validator/src/test/java/io/avaje/validation/core/CustomerValidationAdapter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public boolean validate(Customer value, ValidationRequest request, String proper
5353
activeDateAdapter.validate(value.activeDate, request, "activeDate");
5454

5555
final var _billingAddress = value.billingAddress;
56-
if (core.required(_billingAddress, request, "billingAddress")) { // required / NotNull
5756
addressValidator.validate(_billingAddress, request, "billingAddress");
58-
}
5957

6058
final var _shippingAddress = value.shippingAddress;
6159
if (_shippingAddress != null) { // is nullable

0 commit comments

Comments
 (0)