本文整理汇总了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");
}
}
示例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");
}
}
}
示例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");
}
}
示例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");
}
}
}
示例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");
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}