-
Notifications
You must be signed in to change notification settings - Fork 38k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
170 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...t/src/main/java/org/springframework/validation/beanvalidation/MethodValidationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2002-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.validation.beanvalidation; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import jakarta.validation.ConstraintViolation; | ||
|
||
/** | ||
* Container for method validation results where underlying | ||
* {@link ConstraintViolation violations} have been adapted to | ||
* {@link ParameterValidationResult} each containing a list of | ||
* {@link org.springframework.context.MessageSourceResolvable} grouped by method | ||
* parameter. | ||
* | ||
* <p>For {@link jakarta.validation.Valid @Valid}-annotated, Object method | ||
* parameters or return types with cascaded violations, the {@link ParameterErrors} | ||
* subclass of {@link ParameterValidationResult} implements | ||
* {@link org.springframework.validation.Errors} and exposes | ||
* {@link org.springframework.validation.FieldError field errors}. | ||
* | ||
* @author Rossen Stoyanchev | ||
* @since 6.1 | ||
*/ | ||
public interface MethodValidationResult { | ||
|
||
/** | ||
* Returns the set of constraint violations reported during a validation. | ||
* @return the {@code Set} of {@link ConstraintViolation}s, or an empty Set | ||
*/ | ||
Set<ConstraintViolation<?>> getConstraintViolations(); | ||
|
||
/** | ||
* Return all validation results. This includes method parameters with | ||
* constraints declared on them, as well as | ||
* {@link jakarta.validation.Valid @Valid} method parameters with | ||
* cascaded constraints. | ||
* @see #getValueResults() | ||
* @see #getBeanResults() | ||
*/ | ||
List<ParameterValidationResult> getAllValidationResults(); | ||
|
||
/** | ||
* Return only validation results for method parameters with constraints | ||
* declared directly on them. This excludes | ||
* {@link jakarta.validation.Valid @Valid} method parameters with cascaded | ||
* constraints. | ||
* @see #getAllValidationResults() | ||
*/ | ||
List<ParameterValidationResult> getValueResults(); | ||
|
||
/** | ||
* Return only validation results for {@link jakarta.validation.Valid @Valid} | ||
* method parameters with cascaded constraints. This excludes method | ||
* parameters with constraints declared directly on them. | ||
* @see #getAllValidationResults() | ||
*/ | ||
List<ParameterErrors> getBeanResults(); | ||
|
||
/** | ||
* Check if {@link #getConstraintViolations()} is empty, and if not, raise | ||
* {@link MethodValidationException}. | ||
* @throws MethodValidationException if the result contains any violations | ||
*/ | ||
void throwIfViolationsPresent(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters