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


Java ValidationUtils.rejectIfEmptyOrWhitespace方法代码示例

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


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

示例1: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的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

示例2: validate

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

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "field.required",
            "User Id must not be empty.");

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

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "primaryColor", "field.required",
            "Primary Color must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "secondaryColor", "field.required",
            "Secondary Color must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accentColor", "field.required",
            "Accent Color must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "neutralLightColor", "field.required",
            "Neutral Light Color must not be empty");


    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "neutralDarkColor", "field.required",
            "Neutral Dark Color must not be empty");
}
 
开发者ID:jackcmeyer,项目名称:SmartSync,代码行数:27,代码来源:UserPreferencesValidator.java

示例3: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
@Override
public void validate(Object target, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "field.required");

    User user = (User) target;

    passwordValidator.validate(user.getRawPassword(), errors);
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:10,代码来源:UserValidator.java

示例4: validate

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

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "NotEmpty");
//        if (user.getUsername().length() < 6 || user.getUsername().length() > 32) {
//            errors.rejectValue("username", "Size.userForm.username");
//        }
        if (userService.findByUsername(user.getUsername()) != null) {
            errors.rejectValue("username", "Duplicate.userForm.username");
        }

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty");
//        if (user.getPassword().length() < 8 || user.getPassword().length() > 32) {
//            errors.rejectValue("password", "Size.userForm.password");
//        }

        if (!user.getPasswordConfirm().equals(user.getPassword())) {
            errors.rejectValue("passwordConfirm", "Diff.userForm.passwordConfirm");
        }
    }
 
开发者ID:bndynet,项目名称:web-framework-for-java,代码行数:22,代码来源:UserValidator.java

示例5: validate

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

    UpdateTaskDTO updateTaskDTO = (UpdateTaskDTO) o;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "taskId", "field.required",
            "User Id must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "field.required", "" +
            "Description must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dueDate", "field.required",
            "Due Date must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isCompleted", "field.required",
            "Is Completed must not be empty");
}
 
开发者ID:jackcmeyer,项目名称:SmartSync,代码行数:18,代码来源:UpdateTaskValidator.java

示例6: validate

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

    WeatherLocationDTO weatherLocationDTO = (WeatherLocationDTO) object;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "field.required",
            "User Id 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");

    if(!errors.hasErrors()) {
        if(weatherLocationDTO.getState().length() != 2) {
            errors.rejectValue("state", "filed.invalid",
                    "State must be length 2. Did you forget to use state code?");
        }

    }


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

示例7: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void validate(Object target, Errors errors) {
    UserProfileForm form = (UserProfileForm) target;

    UserProfileVO profile = form.getUserProfile();
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userProfile.firstName",
            "error.valueEmpty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userProfile.lastName",
            "error.valueEmpty");

    validateString(profile.getFirstName(), "userProfile.firstName", errors);
    validateString(profile.getLastName(), "userProfile.lastName", errors);
    validateString(profile.getSalutation(), "userProfile.salutation", errors);
    validateString(profile.getPosition(), "userProfile.position", errors);
    validateString(profile.getCompany(), "userProfile.company", errors);

    validateString(profile.getStreet(), "userProfile.street", errors);
    validateString(profile.getZip(), "userProfile.zip", errors);
    validateString(profile.getCity(), "userProfile.city", errors);
    ValidationHelper.validatePhoneNumber(profile.getPhone(), "phone", errors, false);
    ValidationHelper.validatePhoneNumber(profile.getFax(), "fax", errors, false);
    if (StringUtils.isEmpty(form.getLanguageCode())) {
        errors.rejectValue("languageCode", "error.valueEmpty");
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:28,代码来源:UserManagementUserProfileValidator.java

示例8: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void validate(InviteUserForm form, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAlias", "error.valueEmpty");
    if (!errors.hasFieldErrors("emailAlias")) {
        if (form.getEmailAlias().contains("@")) {
            if (!EmailValidator.validateEmailAddressByRegex(form.getEmailAlias())) {
                errors.rejectValue("emailAlias", "error.email.not.valid",
                        "The entered email address is not valid!");
            }
        } else {
            if (!form.getEmailAlias().matches(ValidationPatterns.PATTERN_ALIAS)) {
                errors.rejectValue("emailAlias", "error.alias.not.valid",
                        "The entered login is not valid!");
            }
        }
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:21,代码来源:EmailAliasInvitationField.java

示例9: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
@Override
public void validate(Object obj, Errors errors) {
	Home homeForm = (Home) obj;
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "message",
			"message.empty");
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "quote",
			"quote.empty");

	if (homeForm.getMessage().length() > 500) {
		errors.rejectValue("message", "message.maxlength");
	}
	if (homeForm.getMessage().length() < 50) {
		errors.rejectValue("message", "message.minlength");
	}

	if (homeForm.getQuote().length() > 500) {
		errors.rejectValue("quote", "quote.maxlength");
	}
	if (homeForm.getQuote().length() < 50) {
		errors.rejectValue("quote", "quote.minlength");
	}
}
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:23,代码来源:IndexValidator.java

示例10: validateServerSettings

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
/**
 * Validates the server settings.
 * 
 * @param form
 *            The form.
 * @param errors
 *            The errors.
 */
private void validateServerSettings(MailInForm form, Errors errors) {

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "server", "string.validation.empty");

    ValidationHelper.validatePortNumber("port", form.getPort(), false, errors);

    if (form.getProtocol() == null
            || !Pattern.matches("imap(s)?", form.getProtocol().getName())) {
        errors.rejectValue("protocol",
                "client.system.communication.mail.in.server.protocol.hint");
    }
    if (StringUtils.isBlank(form.getReconnectionTimeout())
            || !form.getReconnectionTimeout().matches("\\d+")) {
        errors.rejectValue("reconnectionTimeout", "string.validation.numbers.positive");
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mailbox", "string.validation.empty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "login", "string.validation.empty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "string.validation.empty");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:29,代码来源:MailInValidator.java

示例11: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.springframework.validation.Validator#validate(Object,
 *      org.springframework.validation.Errors)
 */
public void validate(Object target, Errors errors) {
    ClientProfileEmailForm form = (ClientProfileEmailForm) target;
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "clientEmail", "error.valueEmpty");
    if (!errors.hasFieldErrors("clientEmail")) {
        if (!EmailValidator.validateEmailAddressByRegex(form.getClientEmail())) {
            errors.rejectValue("clientEmail", "error.email.not.valid",
                    "The entered email address is not valid!");
        }
    }
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "clientEmailName", "error.valueEmpty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "clientSupportEmailAddress",
            "error.valueEmpty");
    if (!errors.hasFieldErrors("clientSupportEmailAddress")) {
        if (!EmailValidator.validateEmailAddressByRegex(form.getClientSupportEmailAddress())) {
            errors.rejectValue("clientSupportEmailAddress", "error.email.not.valid",
                    "The entered email address is not valid!");
        }
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:27,代码来源:ClientProfileEmailValidator.java

示例12: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
public void validate(StoredSubmittable target, SubmittableRepository repository, Errors errors) {
    StoredSubmittable storedVersion = null;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "submission", "required", "submission is required");

    if (errors.hasErrors()){
        return;
    }

    if (target.getId() != null) {
        storedVersion = (StoredSubmittable) repository.findOne(target.getId());
    }

    this.validateAlias(target,repository,errors);

    this.validate(target, storedVersion, errors);
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:18,代码来源:CoreSubmittableValidationHelper.java

示例13: validate

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

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "direccion", "NotEmpty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localidad", "NotEmpty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "provincia", "NotEmpty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "codigoPostal", "NotEmpty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "telefono", "NotEmpty");
}
 
开发者ID:EventSoftGroup,项目名称:EventSoft,代码行数:11,代码来源:UserValidator.java

示例14: validate

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

    TodoTaskDTO todoTaskDTO = (TodoTaskDTO) o;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "todoListId", "field.required",
            "To Do List Id must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "field.required",
            "Description must not be empty.");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dueDate", "field.required",
            "Due Date must not be empty.");
}
 
开发者ID:jackcmeyer,项目名称:SmartSync,代码行数:15,代码来源:TodoTaskValidator.java

示例15: validate

import org.springframework.validation.ValidationUtils; //导入方法依赖的package包/类
@Override
public void validate(Object model, Errors errors) {
	EmployeeForm empForm = (EmployeeForm) model;
	
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "empty.firstName");
	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "empty.lastName");
	
	if(empForm.getAge() < 0) errors.rejectValue("age", "negative.age");
	if(empForm.getAge() > 65) errors.rejectValue("age", "retirable.age");
	
	if(empForm.getBirthday().before(new Date(50,0,1))) errors.rejectValue("birthday", "old.birthday");
	Date now = new Date();
	if(empForm.getBirthday().getYear() == now.getYear() || empForm.getBirthday().before(new Date(99,0,1))) errors.rejectValue("birthday", "underage.birthday");
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:15,代码来源:EmployeeValidator.java


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