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


Java Errors.reject方法代码示例

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


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

示例1: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object target, Errors errors) {
    if (target == null) {
        errors.reject("null", "request must not be null");
    }

}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:8,代码来源:UpdateAccessCertificateSignatureRequestValidator.java

示例2: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object o, Errors errors) {
    Geolocation geolocation = (Geolocation) o;

    if(geolocation.getLatitude()> 90.0 || geolocation.getLatitude()< -90.0){
        errors.reject("latitude", "latitude.outOfRange");
    }

    if(geolocation.getLongitude()> 180.0 || geolocation.getLatitude()<-180.0){
        errors.reject("longitude", "longitude.outOfRange");
    }

}
 
开发者ID:nicolasmanic,项目名称:Facegram,代码行数:14,代码来源:GeolocationValidator.java

示例3: validateUsername

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateUsername(Errors errors, UserDTO form, long userId) {
    User user = userService.getUserByUsername(form.getUsername());
    if (user != null) {
        if (user.getId() != userId) {
            errors.reject("user.exists", "User with this username already exists");
        }
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:UserCreateFormValidator.java

示例4: validateForMinMaxFileSize

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateForMinMaxFileSize(Errors errors, ProfileImageDTO profileImage) {
    if (profileImage.getFile().getSize() == 0) {
        errors.reject("file.empty");
    }
    if (profileImage.getFile().getSize() > imageMaxSize) {
        errors.reject("file.too.large");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:ProfileImageValidator.java

示例5: preventDemoUserUpdate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void preventDemoUserUpdate(Errors errors, UserPasswordDTO form) {
    Optional<User> user = userService.getUserById(form.getUserId());
    if (user.isPresent()) {
        if (user.get().getUsername().toLowerCase().equals("user")) {
            errors.reject("global.error.password.demo.user");
        }
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:UserPasswordValidator.java

示例6: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
public void validate(String language, Data data, Errors errors) {
    if (!"de-DE".equals(language)) {
        if (data.getSomeStringValue().length() > 140) {
            errors.reject("someStringValue");
        }
    }
}
 
开发者ID:rbraeunlich,项目名称:spring-boot-additional-validation,代码行数:8,代码来源:StringValueValidator.java

示例7: valideer

import org.springframework.validation.Errors; //导入方法依赖的package包/类
/**
 * Voer een validatie uit.
 * @param errors errors object
 * @param validatie true als validatie is geslaagd, anders false
 * @param veld veld code (voor errors object)
 * @param foutcode fout code (voor errors object)
 * @param argumenten argumenten (voor errors object)
 */
public static void valideer(final Errors errors, final boolean validatie, final String veld, final String foutcode, final String... argumenten) {
    if (!validatie) {
        if (veld == null || "".equals(veld)) {
            errors.reject(foutcode, argumenten, foutcode);
        } else {
            errors.rejectValue(veld, foutcode, argumenten, foutcode);
        }
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:18,代码来源:ValidatieUtils.java

示例8: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object target, Errors errors) {
    if (target == null) {
        errors.reject("null", "request must not be null");
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "appId", "appId.empty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "deviceSerialNumber", "deviceSerialNumber.empty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "vehicleSerialNumber", "vehicleSerialNumber.empty");

    CreateAccessCertificateRequestDto request = (CreateAccessCertificateRequestDto) target;
    boolean isDeviceSerialNumberLengthValid = request != null &&
            request.getDeviceSerialNumber() != null &&
            request.getDeviceSerialNumber().length() == SERIAL_NUMBER_LENGTH;

    if (!isDeviceSerialNumberLengthValid) {
        errors.rejectValue("deviceSerialNumber", "deviceSerialNumber.length");
    }

    boolean isVehicleSerialNumberLengthValid = request != null &&
            request.getVehicleSerialNumber() != null &&
            request.getVehicleSerialNumber().length() == SERIAL_NUMBER_LENGTH;

    if (!isVehicleSerialNumberLengthValid) {
        errors.rejectValue("vehicleSerialNumber", "vehicleSerialNumber.length");
    }

    boolean isValidFromOrUntilMissing = request != null && (request.getValidityStart() == null || request.getValidityEnd() == null);
    if (isValidFromOrUntilMissing) {
        // TODO: while in prototype phase, we can set valid dates ourselves..
        // TODO: but raise error if "valid from" and "valid until" are missing in final release!
        LocalDateTime validFrom = LocalDateTime.now();
        LocalDateTime validUntil = validFrom.plusDays(1)
                .toLocalDate().atStartOfDay();

        request.setValidityStart(validFrom.toInstant(ZoneOffset.UTC));
        request.setValidityEnd(validUntil.toInstant(ZoneOffset.UTC));

        log.warn("Fill missing validity dates of CreateAccessCertificateRequestDto with: from {}, to {}", validFrom, validUntil);
    }
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:42,代码来源:CreateAccessCertificateRequestValidator.java

示例9: validatePasswords

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validatePasswords(Errors errors, UserDTO form) {
    if (!form.getPassword().equals(form.getRepeatedPassword())) {
        errors.reject("password.no_match", "Passwords do not match");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:6,代码来源:UserCreateFormValidator.java

示例10: validateEmail

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateEmail(Errors errors, UserDTO form) {
    if (userService.getByEmail(form.getEmail()).isPresent()) {
        errors.reject("email.exists", "User with this email already exists");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:6,代码来源:UserCreateFormValidator.java

示例11: validateDomain

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateDomain(Errors errors, UserDTO form) {
    if (!accessService.isEmailApproved(form.getEmail())) {
        errors.reject("domain.not.approved",
                "The email address domain is not currently supported");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:7,代码来源:UserCreateFormValidator.java

示例12: validatePasswords

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validatePasswords(Errors errors, UserPasswordDTO form) {
    if (!form.getPassword().equals(form.getRepeatedPassword())) {
        errors.reject("password.no_match", "Passwords do not match");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:6,代码来源:UserPasswordValidator.java

示例13: validateEmail

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateEmail(Errors errors, SocialUserDTO form) {
    if (userService.getByEmail(form.getEmail()).isPresent()) {
        errors.reject("email.exists", "User with this email already exists");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:6,代码来源:SocialUserFormValidator.java

示例14: validateUsername

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateUsername(Errors errors, SocialUserDTO form) {
    if (userService.getUserByUsername(form.getUsername()) != null) {
        errors.reject("user.exists", "User with this username already exists");
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:6,代码来源:SocialUserFormValidator.java


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