本文整理匯總了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.");
}
}
}
示例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.");
}
}
}
示例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");
}
}
示例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");
}
}
}
示例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");
}
}
}
示例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");
}
}
示例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");
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
示例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!");
}
示例15: validate
import org.springframework.validation.ValidationUtils; //導入方法依賴的package包/類
public void validate(Object target, Errors errors) {
ValidationUtils.rejectIfEmpty(errors, "motiu", "not.blank");
}