當前位置: 首頁>>代碼示例>>Java>>正文


Java ValidationUtils.rejectIfEmpty方法代碼示例

本文整理匯總了Java中org.springframework.validation.ValidationUtils.rejectIfEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java ValidationUtils.rejectIfEmpty方法的具體用法?Java ValidationUtils.rejectIfEmpty怎麽用?Java ValidationUtils.rejectIfEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.validation.ValidationUtils的用法示例。


在下文中一共展示了ValidationUtils.rejectIfEmpty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
/**
 * Validates the input
 * @param object the user to validate
 * @param errors the errors
 */
public void validate(Object object, Errors errors) {

    UserDTO user = (UserDTO) object;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "googleId", "field.required",
            "googleId must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fullName", "field.required",
            "User Full Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "givenName", "field.required",
            "User Given Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "familyName", "field.required",
            "User Family Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "imageURL", "field.required",
            "User Image URL must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "field.required",
            "User Email must not be empty");
    ValidationUtils.rejectIfEmpty(errors, "role", "field.required",
            "User Role must not be empty.");

    // doing specific input validaiton, so we need to make sure all of the fields are there
    if(!errors.hasErrors()) {
        if(user.getRole() < 0 || user.getRole() > 1) {
            errors.rejectValue("role", "field.invalid", "User Role must be 0 or 1");
        }

        if(!EmailValidator.getInstance().isValid(user.getEmail())) {
            errors.rejectValue("email", "field.invalid", "User Email must be a valid email address.");
        }

        if(!UrlValidator.getInstance().isValid(user.getImageURL())) {
            errors.rejectValue("imageURL", "field.invalid", "User Image URl must be a valid web address.");
        }
    }



}
 
開發者ID:jackcmeyer,項目名稱:SmartSync,代碼行數:43,代碼來源:UserValidator.java

示例2: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
@Override
public void validate(Object o, Errors errors) {
    UpdateUserDTO user = (UpdateUserDTO) o;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "field.required",
            "User Id must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "googleId", "field.required",
            "googleId must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fullName", "field.required",
            "User Full Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "givenName", "field.required",
            "User Given Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "familyName", "field.required",
            "User Family Name must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "imageURL", "field.required",
            "User Image URL must not be empty.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "field.required",
            "User Email must not be empty");
    ValidationUtils.rejectIfEmpty(errors, "role", "field.required",
            "User Role must not be empty.");

    // doing specific input validaiton, so we need to make sure all of the fields are there
    if(!errors.hasErrors()) {
        if(user.getRole() < 0 || user.getRole() > 1) {
            errors.rejectValue("role", "field.invalid", "User Role must be 0 or 1");
        }

        if(!EmailValidator.getInstance().isValid(user.getEmail())) {
            errors.rejectValue("email", "field.invalid", "User Email must be a valid email address.");
        }

        if(!UrlValidator.getInstance().isValid(user.getImageURL())) {
            errors.rejectValue("imageURL", "field.invalid", "User Image URl must be a valid web address.");
        }
    }
}
 
開發者ID:jackcmeyer,項目名稱:SmartSync,代碼行數:37,代碼來源:UpdateUserValidator.java

示例3: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	Date avui = new Date();
	ReassignacioUsuarisCommand command = (ReassignacioUsuarisCommand)target;
	ValidationUtils.rejectIfEmpty(errors, "usuariOrigen", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "usuariDesti", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "dataInici", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "dataFi", "not.blank");
	if ((command.getDataInici() != null) && (avui.compareTo(command.getDataInici()) > 0)) {
		errors.rejectValue("dataInici", "error.data.anterior");
	}
	if ((command.getDataFi() != null) && (avui.compareTo(command.getDataFi()) > 0)) {
		errors.rejectValue("dataFi", "error.data.anterior");
	}
	if ((command.getDataInici() != null) && (command.getDataFi() != null) && ((command.getDataFi()).compareTo(command.getDataInici()) < 0)) {
		errors.rejectValue("dataFi", "error.dataFi.anterior");
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:18,代碼來源:ReassignacioUsuarisValidatorHelper.java

示例4: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	Domini domini = (Domini)target;
	if (domini.getTipus()!=null) {
		if (domini.getTipus().equals(TipusDomini.CONSULTA_WS)) {
			ValidationUtils.rejectIfEmpty(errors, "url", "not.blank");
			if (!TipusAuthDomini.NONE.equals(domini.getTipusAuth())) {
				ValidationUtils.rejectIfEmpty(errors, "usuari", "not.blank");
				ValidationUtils.rejectIfEmpty(errors, "contrasenya", "not.blank");
			}
		}
		if (domini.getTipus().equals(TipusDomini.CONSULTA_SQL)) {
			ValidationUtils.rejectIfEmpty(errors, "jndiDatasource", "not.blank");
			ValidationUtils.rejectIfEmpty(errors, "sql", "not.blank");
		}
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:17,代碼來源:ExpedientTipusDominisController.java

示例5: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	PersonaUsuariCommand command = (PersonaUsuariCommand)target;
	// El codi d'usuari no pot estar repetit
	Persona repetida = personaService.findPersonaAmbCodi(command.getCodi());
	if (repetida != null && !repetida.getId().equals(command.getId())) {
		errors.rejectValue("codi", "error.persona.codi.repetit");
	}
	// Si l'usuari pot fer login la contrasenya i la repetició són obligatoris
	if (command.isLogin() && command.getId() == null) {
		ValidationUtils.rejectIfEmpty(errors, "contrasenya", "not.blank");
		ValidationUtils.rejectIfEmpty(errors, "repeticio", "not.blank");
	}
	// La contrasenya i la repetició han de coincidir
	if (command.getContrasenya() != null) {
		if (command.getRepeticio() == null || !command.getRepeticio().equals(command.getContrasenya())) {
			errors.rejectValue("contrasenya", "error.contrasenya.repeticio");
			errors.rejectValue("repeticio", "error.contrasenya.repeticio");
		}
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:21,代碼來源:PersonaController.java

示例6: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	Calendar cal = Calendar.getInstance();
	cal.setTime(new Date());
	cal.set(Calendar.HOUR_OF_DAY, 0);
	cal.set(Calendar.MINUTE, 0);
	cal.set(Calendar.SECOND, 0);
	cal.set(Calendar.MILLISECOND, 0);
	Date avui = cal.getTime();
	
	ReassignacioCommand command = (ReassignacioCommand)target;
	ValidationUtils.rejectIfEmpty(errors, "usuariOrigen", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "usuariDesti", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "dataInici", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "dataFi", "not.blank");
	if ((command.getDataInici() != null) && (avui.compareTo(command.getDataInici()) > 0)) {
		errors.rejectValue("dataInici", "error.data.anterior");
	}
	if ((command.getDataFi() != null) && (avui.compareTo(command.getDataFi()) > 0)) {
		errors.rejectValue("dataFi", "error.data.anterior");
	}
	if ((command.getDataInici() != null) && (command.getDataFi() != null) && ((command.getDataFi()).compareTo(command.getDataInici()) < 0)) {
		errors.rejectValue("dataFi", "error.dataFi.anterior");
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:25,代碼來源:ReassignacioController.java

示例7: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	MapeigSistra command = (MapeigSistra)target;
	ValidationUtils.rejectIfEmpty(errors, "codiHelium", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "codiSistra", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "tipus", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "expedientTipus", "not.blank");
	
	
	if (command.getCodiHelium() != null && !("".equalsIgnoreCase(command.getCodiHelium())) && command.getExpedientTipus() != null) {	
		MapeigSistra repetits = dissenyService.findMapeigSistraAmbExpedientTipusICodi(command.getExpedientTipus().getId(), command.getCodiHelium());
		if (repetits != null) {
			errors.rejectValue("codiHelium", "error.expedienttipus.sistra.mapeig.repetit");
		}
	}
	if (command.getCodiHelium().length() > 255) 
		errors.rejectValue("codiHelium", "max.length");
	if (command.getCodiSistra().length() > 255) 
		errors.rejectValue("codiSistra", "max.length");
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:20,代碼來源:ExpedientTipusSistraDocumentsController.java

示例8: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object command, Errors errors) {
	try {
		Long registreId = (Long)PropertyUtils.getSimpleProperty(command, "registreId");
		Camp camp = dissenyService.getCampById(registreId);
		for (CampRegistre campRegistre: camp.getRegistreMembres()) {
			if (campRegistre.isObligatori())
				ValidationUtils.rejectIfEmpty(errors, campRegistre.getMembre().getCodi(), "not.blank");
		}
	} catch (Exception ex) {
		errors.reject("error.validator");
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:13,代碼來源:CommonRegistreHelper.java

示例9: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
@Override
public void validate(Object o, Errors errors) {
	ValidationUtils.rejectIfEmpty(errors, "host", "host.empty");
	ValidationUtils.rejectIfEmpty(errors, "port", "port.empty");
	SampleProperties properties = (SampleProperties) o;
	if (properties.getHost() != null
			&& !this.pattern.matcher(properties.getHost()).matches()) {
		errors.rejectValue("host", "Invalid host");
	}
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:11,代碼來源:SamplePropertiesValidator.java

示例10: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	ExpedientTipusSistraCommand command = (ExpedientTipusSistraCommand)target;
	if (command.isActiu()) {
		ValidationUtils.rejectIfEmpty(errors, "codiTramit", "not.blank");
		if (command.getCodiTramit() != null) {
			List<ExpedientTipus> repetits = dissenyService.findExpedientTipusAmbSistraTramitCodi(command.getCodiTramit());
			if (repetits.size() > 0) {
				if (repetits.get(0).getId().longValue() != command.getExpedientTipusId().longValue())
					errors.rejectValue("codiTramit", "error.expedienttipus.sistra.repetit");
			}
		}
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:14,代碼來源:ExpedientTipusSistraController.java

示例11: action

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
@RequestMapping(params = "action=signup")
public void action(ActionRequest request, ActionResponse response,
		LoginForm loginForm, Errors errors, SessionStatus sessionStatus) {
	ValidationUtils.rejectIfEmpty(errors, "firstName", "firstName.empty",
			"Please, fill in your first name");
	ValidationUtils.rejectIfEmpty(errors, "lastName", "lastName.empty",
			"Please, fill in your last name");
	if (!errors.hasErrors()) {
		response.setRenderParameter("action", "login");
	}
}
 
開發者ID:PacktPublishing,項目名稱:Spring-MVC-Blueprints,代碼行數:12,代碼來源:SignupController.java

示例12: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object obj, Errors errors) {
	if ("user".equals(tipus)) {
		ValidationUtils.rejectIfEmpty(errors, "usuari", "not.blank");
	} else if ("grup".equals(tipus)) {
		ValidationUtils.rejectIfEmpty(errors, "grup", "not.blank");
	} else if ("expr".equals(tipus)) {
		ValidationUtils.rejectIfEmpty(errors, "expression", "not.blank");
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:10,代碼來源:MassivaTascaReassignacioController.java

示例13: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	MapeigSistra command = (MapeigSistra)target;
	ValidationUtils.rejectIfEmpty(errors, "codiHelium", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "tipus", "not.blank");
	ValidationUtils.rejectIfEmpty(errors, "expedientTipus", "not.blank");
	
	if (command.getCodiHelium() != null && !("".equalsIgnoreCase(command.getCodiHelium())) && command.getExpedientTipus() != null) {	
		MapeigSistra repetits = dissenyService.findMapeigSistraAmbExpedientTipusICodi(command.getExpedientTipus().getId(), command.getCodiHelium());
		if (repetits != null) {
			errors.rejectValue("codiHelium", "error.expedienttipus.sistra.mapeig.repetit");
		}
	}
	if (command.getCodiHelium().length() > 255) 
		errors.rejectValue("codiHelium", "max.length");
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:16,代碼來源:ExpedientTipusSistraAdjuntsController.java

示例14: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object obj, Errors errors) {
    ValidationUtils.rejectIfEmpty(errors, "siteName", "EMPTY", "You must enter a site name!");
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:4,代碼來源:SiteOptionTests.java

示例15: validate

import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
	ValidationUtils.rejectIfEmpty(errors, "motiu", "not.blank");
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:4,代碼來源:ExpedientEinesController.java


注:本文中的org.springframework.validation.ValidationUtils.rejectIfEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。