当前位置: 首页>>代码示例>>Java>>正文


Java ConstraintViolation.getInvalidValue方法代码示例

本文整理汇总了Java中javax.validation.ConstraintViolation.getInvalidValue方法的典型用法代码示例。如果您正苦于以下问题:Java ConstraintViolation.getInvalidValue方法的具体用法?Java ConstraintViolation.getInvalidValue怎么用?Java ConstraintViolation.getInvalidValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.validation.ConstraintViolation的用法示例。


在下文中一共展示了ConstraintViolation.getInvalidValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: errorMessage

import javax.validation.ConstraintViolation; //导入方法依赖的package包/类
private String errorMessage(ConstraintViolation<?> error) {
    Set<Class<? extends Payload>> payload = error.getConstraintDescriptor().getPayload();

    if (payload.contains(NoLogging.class)) {
        return error.getPropertyPath().toString() + ", " + error.getMessage();
    } else {
        return error.getPropertyPath().toString() + ", " + error.getMessage() + ", was: " + error.getInvalidValue();
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:10,代码来源:ConstraintViolationExceptionMapper.java

示例2: contOnValidationError

import javax.validation.ConstraintViolation; //导入方法依赖的package包/类
/**
 * Accepts the result from one of the many validation methods available and
 * returns a List of ValidationErrors. If the size of the List is 0, no errors
 * were encounter during validation.
 *
 * Usage:
 * <pre>
 *     Validator validator = getValidator();
 *     List&lt;ValidationError&gt; errors = contOnValidationError(
 *         validator.validateProperty(myObject, "uuid"),
 *         validator.validateProperty(myObject, "name")
 *      );
 *      // If validation fails, this line will be reached.
 * </pre>
 *
 * @param violationsArray a Set of one or more ConstraintViolations
 * @return a List of zero or more ValidationErrors
 * @since 1.0.0
 */
@SafeVarargs
protected final List<ValidationError> contOnValidationError(final Set<ConstraintViolation<Object>>... violationsArray) {
    final List<ValidationError> errors = new ArrayList<>();
    for (Set<ConstraintViolation<Object>> violations : violationsArray) {
        for (ConstraintViolation violation : violations) {
            if (violation.getPropertyPath().iterator().next().getName() != null) {
                final String path = violation.getPropertyPath() != null ? violation.getPropertyPath().toString() : null;
                final String message = violation.getMessage() != null ? StringUtils.removeStart(violation.getMessage(), path + ".") : null;
                final String messageTemplate = violation.getMessageTemplate();
                final String invalidValue = violation.getInvalidValue() != null ? violation.getInvalidValue().toString() : null;
                final ValidationError error = new ValidationError(message, messageTemplate, path, invalidValue);
                errors.add(error);
            }
        }
    }
    return errors;
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:37,代码来源:AlpineResource.java


注:本文中的javax.validation.ConstraintViolation.getInvalidValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。