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