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


Java Errors.rejectValue方法代码示例

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


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

示例1: validate

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

    if (target instanceof PasswordChangeRequest) {
        password = ((PasswordChangeRequest) target).getPassword();
    } else if (target instanceof String) {
        password = target.toString();
    }

    if (password != null && password.length() < MINIMUM_PASSWORD_LENGTH) {
        errors.rejectValue("password", "field.min.length", new Object[]{MINIMUM_PASSWORD_LENGTH},
            "The password must be at least [" + MINIMUM_PASSWORD_LENGTH + "] characters in length.");
    }

}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:17,代码来源:PasswordValidator.java

示例2: validate

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

    FileUpload fileUpload = (FileUpload) obj;
    MultipartFile file = fileUpload.getFile();

    if(file.isEmpty()){
        errors.rejectValue("file", "upload.file.required");
    }
    else if(!PNG_MIME_TYPE_PNG.equalsIgnoreCase(file.getContentType()) && !PNG_MIME_TYPE_JPEG.equalsIgnoreCase(file.getContentType())){
        errors.rejectValue("file", "upload.invalid.file.type");
    }

    else if(file.getSize() > A_MB_IN_BYTES){
        errors.rejectValue("file", "upload.exceeded.file.size");
    }

}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:19,代码来源:FileValidator.java

示例3: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object obj, Errors errors) {
	// TODO Auto-generated method stub
	Book book = (Book) obj;
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "bookName", "bookName.required");
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "author", "authorName.required");

	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "description.required");

	if (book.getDescription().length() < 10 || book.getDescription().length() > 40) {
		errors.rejectValue("description", "description.length",
				"Please enter description within 40 charaters only");
	}

	if (book.getISBN() <= 150l) {
		errors.rejectValue("ISBN", "ISBN.required", "Please Enter Correct ISBN number");
	}

	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "price", "price.incorrect");

	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "publication", "publication.required");

}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:24,代码来源:BookValidator2.java

示例4: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object obj, Errors errors) {
    Pet pet = (Pet) obj;
    String name = pet.getName();
    // name validation
    if (!StringUtils.hasLength(name)) {
        errors.rejectValue("name", REQUIRED, REQUIRED);
    }

    // type validation
    if (pet.isNew() && pet.getType() == null) {
        errors.rejectValue("type", REQUIRED, REQUIRED);
    }

    // birth date validation
    if (pet.getBirthDate() == null) {
        errors.rejectValue("birthDate", REQUIRED, REQUIRED);
    }
}
 
开发者ID:awslabs,项目名称:amazon-ecs-java-microservices,代码行数:20,代码来源:PetValidator.java

示例5: validateClientId

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateClientId(ClientDetailsFormDto clientDetailsDto, Errors errors) {
    final String clientId = clientDetailsDto.getClientId();
    if (StringUtils.isEmpty(clientId)) {
        errors.rejectValue("clientId", null, "client_id is required");
        return;
    }

    if (clientId.length() < 5) {
        errors.rejectValue("clientId", null, "client_id 长度至少5位");
        return;
    }

    boolean existed = oauthService.isExistedClientId(clientId);
    if (existed) {
        errors.rejectValue("clientId", null, "client_id [" + clientId + "] 已存在");
    }

}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:19,代码来源:ClientDetailsFormDtoValidator.java

示例6: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
/**
     * validates the data
     * @param object the household to validate
     * @param errors the errors
     */
    public void validate(Object object, Errors errors) {
        ServiceAndHouseholdDTO serviceAndHouseholdDTO = (ServiceAndHouseholdDTO) object;

        if(serviceAndHouseholdDTO.getServiceId() == null) {
            errors.rejectValue("serviceId", "field.required", "Service ID must not be empty.");
        }

        if(serviceAndHouseholdDTO.getHouseholdId() == null) {
            errors.rejectValue("householdId", "field.required", "Household ID must not be empty.");
        }


//        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "field.required",
//                "User ID must not be empty.");
//
//        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "householdId", "field.required",
//                "Household ID must not be empty.");

    }
 
开发者ID:jackcmeyer,项目名称:SmartSync,代码行数:25,代码来源:ServiceAndHouseholdValidator.java

示例7: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object obj, Errors errors) {
	// TODO Auto-generated method stub
	Book book=(Book) obj;
	if (book.getBookName().length() < 5) {
		errors.rejectValue("bookName", "bookName.required");
	}

	if (book.getAuthor().length() <=0) {
		errors.rejectValue("author", "authorName.required");
				
	}

	if (book.getDescription().length() <= 0)
	{
		errors.rejectValue("description", "description.required");
				
	}
	else if (book.getDescription().length() < 10 || book.getDescription().length() <  40) {
		errors.rejectValue("description", "description.length");
				
	}
	
	if (book.getISBN()<=150l) {
		errors.rejectValue("ISBN", "ISBN.required");
				
	}
	
	if (book.getPrice()<=0 ) {
		errors.rejectValue("price", "price.incorrect");
	}

	if (book.getPublication().length() <=0) {
		errors.rejectValue("publication", "publication.required");
		
	}
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:38,代码来源:BookValidator1.java

示例8: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
/**
 * validates the data
 * @param object the household to validate
 * @param errors the errors
 */
public void validate(Object object, Errors errors) {
    HouseholdDTO household = (HouseholdDTO) object;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "householdName", "field.required",
            "Household name must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ownerId", "field.required",
            "Owner ID must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstAddressLine", "filed.required",
            "First Address Line must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "city", "field.required",
            "City must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "state", "field.required",
            "State must not be empty.");

    /**
     * Doing specific validation, must not have any errors from above
     */
    if(!errors.hasErrors()) {
        if(Integer.toString(household.getZipCode()).length() != 5) {
            errors.rejectValue("zipCode", "field.length", "Zip Code must be 5 digits");
        }

        if(household.getState().length() != 2) {
            errors.rejectValue("state", "field.length",
                    "State Code must be 2 characters long. Did you send the full length name instead?");
        }
    }
}
 
开发者ID:jackcmeyer,项目名称:SmartSync,代码行数:38,代码来源:HouseholdValidator.java

示例9: 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

示例10: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
/**
 * This validate() method checks for all the validations related to Add Timesheet Information.
 */
@Override
public void validate(Object target, Errors errors) {

    Timesheet timesheetObj = (Timesheet) target;
    //Check if the Regular Hours are greater than 40 hours per week
    if (timesheetObj.getRegularHours() > 40) {
        errors.rejectValue("regularHours", "NotValid.timesheet.regularHours");
    }

    if (StringUtils.isBlank(timesheetObj.getDscFileName())) {
        errors.rejectValue("uploadFile", "NotEmpty.timesheet.file");
    }

    if (!fileNameUtils.validFileName(timesheetObj.getDscFileName())) {
        errors.rejectValue("uploadFile", "NotValid.timesheet.file.name");
    }

    if (!fileNameUtils.validFileType(timesheetObj.getDscFileName())) {
        errors.rejectValue("uploadFile", "NotValid.timesheet.file.type");
    }

    if (!fileNameUtils.validFileSize(timesheetObj.getFileSize())) {
        errors.rejectValue("uploadFile", "NotValid.timesheet.file.size");
    }


}
 
开发者ID:Mahidharmullapudi,项目名称:timesheet-upload,代码行数:31,代码来源:TimesheetValidator.java

示例11: validateClientSecret

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateClientSecret(ClientDetailsFormDto clientDetailsDto, Errors errors) {
    final String clientSecret = clientDetailsDto.getClientSecret();
    if (StringUtils.isEmpty(clientSecret)) {
        errors.rejectValue("clientSecret", null, "client_secret is required");
        return;
    }

    if (clientSecret.length() < 8) {
        errors.rejectValue("clientSecret", null, "client_secret 长度至少8位");
    }
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:12,代码来源:ClientDetailsFormDtoValidator.java

示例12: validateUsername

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validateUsername(Errors errors, UsersFormDto formDto) {
    final String username = formDto.getUsername();
    if (StringUtils.isEmpty(username)) {
        errors.rejectValue("username", null, "Username is required");
        return;
    }

    boolean existed = userService.isExistedUsername(username);
    if (existed) {
        errors.rejectValue("username", null, "Username already existed");
    }

}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:14,代码来源:UsersFormDtoValidator.java

示例13: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
@Override
public void validate(Object obj, Errors errors) {
	// TODO Auto-generated method stub
	Book book=(Book) obj;
	if (book.getBookName().length() < 5) {
		errors.rejectValue("bookName", "bookName.required",
				"Please Enter the book Name");
	}

	if (book.getAuthor().length() <=0) {
		errors.rejectValue("author", "authorName.required",
				"Please Enter Author's Name");
	}

	if (book.getDescription().length() <= 0)
	{
		errors.rejectValue("description", "description.required",
				"Please enter book description");
	}
	else if (book.getDescription().length() < 10 || book.getDescription().length() >  40) {
		errors.rejectValue("description", "description.length",
				"Please enter description within 40 charaters only");
	}
	
	if (book.getISBN()<=150l) {
		errors.rejectValue("ISBN", "ISBN.required",
				"Please Enter Correct ISBN number");
	}
	
	if (book.getPrice()<=0 ) {
		errors.rejectValue("price", "price.incorrect",	"Please enter a Correct correct price");
	}

	if (book.getPublication().length() <=0) {
		errors.rejectValue("publication", "publication.required",
				"Please enter publication ");

	}


}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:42,代码来源:BookValidator.java

示例14: validate

import org.springframework.validation.Errors; //导入方法依赖的package包/类
public void validate(Object arg0, Errors errors) {

		HotnessInfo hotnessInfo = (HotnessInfo) arg0;

		ShoppingCart cart = TajUtils.getOrderFromSession(request);

		/*if (hotnessInfo.getHotnessLevel() == null){// && TajUtils.categoriesForHotnessLevel().contains(cart.getCartItem().get(0).getProductInfo().getCategoryId()) ) {
			errors.rejectValue("hotnessLevel[0]", "NotEmpty.hotness.value");
		} else {
			List<String> a = hotnessInfo.getHotnessLevel();
			
			if (a != null && cart != null) {
				int i=0;
				for (ItemInfo info:cart.getCartItem()) {
					try {
						if (TajUtils.categoriesForHotnessLevel().contains(info.getProductInfo().getCategoryId()) && a.get(i) == null) {
							errors.rejectValue("hotnessLevel[" + i + "]", "NotEmpty.hotness.value");
						}
							
					} catch (IndexOutOfBoundsException e) {
						errors.rejectValue("hotnessLevel[" + i + "]", "NotEmpty.hotness.value");
					}
					i++;

				}
			}

		}*/
		
		
		int count=0;
		List<String> a = hotnessInfo.getHotnessLevel();
		
		for(ItemInfo info:cart.getCartItem()){
			
			if(TajUtils.categoriesForHotnessLevel().contains(info.getProductInfo().getCategoryId())){
				try{
					if(a==null){
						errors.rejectValue("hotnessLevel[" + count + "]", "NotEmpty.hotness.value");
						break;
					}else if(a.get(count)==null){
						errors.rejectValue("hotnessLevel[" + count + "]", "NotEmpty.hotness.value");
						break;
					}else{
						count++;
					}
				}catch (IndexOutOfBoundsException e) {
					errors.rejectValue("hotnessLevel[" + count + "]", "NotEmpty.hotness.value");
				}
				
				
			}
			
		}
		

	}
 
开发者ID:axd164330,项目名称:Restaurant,代码行数:58,代码来源:HotnessValidator.java

示例15: validatePassword

import org.springframework.validation.Errors; //导入方法依赖的package包/类
private void validatePassword(SignupForm form, Errors errors){
    String password = form.getPassword();
    if(password == null || !password.equals(form.getPasswordConfirmation())){
        errors.rejectValue("password", "password.equal", "Passwords do not match");
    }
}
 
开发者ID:peterjurkovic,项目名称:travel-agency,代码行数:7,代码来源:SignupFormValidator.java


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