File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
blackbox-test/src/test/java/example/avaje/crossfield
validator/src/main/java/io/avaje/validation/core Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ void valid() {
23
23
void invalid_classLevelValidation () {
24
24
var violation = one (new ATarnished ("ok" , 49 , 50 ));
25
25
assertThat (violation .message ()).isEqualTo ("put these foolish ambitions to rest" );
26
- assertThat (violation .path ()).isEqualTo ("null " );
27
- assertThat (violation .field ()).isNull ( );
26
+ assertThat (violation .path ()).isEqualTo ("" );
27
+ assertThat (violation .field ()).isEqualTo ( "" );
28
28
}
29
29
30
30
Original file line number Diff line number Diff line change @@ -52,12 +52,17 @@ private String currentPath() {
52
52
@ Override
53
53
public void addViolation (ValidationContext .Message msg , String propertyName ) {
54
54
final String message = validator .interpolate (msg , locale );
55
- violations .add (new ConstraintViolation (currentPath () + propertyName , propertyName , message ));
55
+ final String field = field (propertyName );
56
+ violations .add (new ConstraintViolation (currentPath () + field , field , message ));
56
57
if (failfast ) {
57
58
throwWithViolations ();
58
59
}
59
60
}
60
61
62
+ private String field (String propertyName ) {
63
+ return propertyName == null ? "" : propertyName ;
64
+ }
65
+
61
66
@ Override
62
67
public void pushPath (String path ) {
63
68
pathStack .push (path );
You can’t perform that action at this time.
0 commit comments