Example usage for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace

List of usage examples for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace

Introduction

In this page you can find the example usage for org.springframework.validation ValidationUtils rejectIfEmptyOrWhitespace.

Prototype

public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode) 

Source Link

Document

Reject the given field with the given error code if the value is empty or just contains whitespace.

Usage

From source file:com.wisemapping.validator.Utils.java

static void validateEmailAddress(final String email, final Errors errors) {
    if (email == null || email.trim().length() == 0) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", Messages.FIELD_REQUIRED);
    } else {/*w w w  .j a v  a2 s.  c om*/
        boolean isValid = Utils.isValidateEmailAddress(email);
        if (!isValid) {
            errors.rejectValue("email", Messages.NO_VALID_EMAIL_ADDRESS);
        }
    }
}

From source file:org.tsm.concharto.web.util.AuthFormValidatorHelper.java

public static void validateEmail(AuthForm authForm, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "empty.authForm.email");
}

From source file:org.codeqinvest.web.validation.ValidationHelper.java

/**
 * Validates if a given field is not empty or blank and uses
 * default error message key when violated.
 */// w w w .  j  av  a  2s .  co  m
public static void rejectIfEmptyOrWhitespace(Errors errors, String field) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, field, FIELD_REQUIRED);
}

From source file:org.tsm.concharto.web.util.AuthFormValidatorHelper.java

public static void validateUsernamePasswordFields(AuthForm authForm, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "empty.authForm.username");
    validatePasswordFields(authForm, errors);
}

From source file:com.mtech.easyexchange.validator.RegistrationValidator.java

@Override
public void validate(Object target, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "email.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required");

}

From source file:cz.muni.fi.pa165.bookingmanager.validators.HotelValidator.java

@Override
public void validate(Object o, Errors errors) {
    HotelTO user = (HotelTO) o;//w  w  w. j  av a  2 s.c o m
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "hotel.validation.error.firstName");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address", "hotel.validation.error.lastName");

}

From source file:cz.muni.fi.pa165.bookingmanager.validators.UserValidator.java

@Override
public void validate(Object o, Errors errors) {
    UserTO user = (UserTO) o;/* ww  w  .  jav a 2 s . c  o  m*/
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "user.validation.error.firstName");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "user.validation.error.lastName");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "user.validation.error.email");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "user.validation.error.username");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "user.validation.error.password");

}

From source file:com.springmvc.videoteca.spring.validator.SalaFormValidator.java

@Override
public void validate(Object o, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "numero", "NotEmpty.salaForm.numero");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tipo", "NotEmpty.salaForm.tipo");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "capacidad", "NotEmpty.salaForm.capacidad");

}

From source file:com.test.springmvc.springmvcproject.validator.RegisterValidator.java

@Override
public void validate(Object o, Errors errors) {
    RegisterBean bean = (RegisterBean) o;
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, bean.getEmail(), "Email requis !");
}

From source file:contact.form.ContactValidator.java

@Override
public void validate(Object target, Errors errors) {

    if (target instanceof Contact) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstname", "field.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastname", "field.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "field.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "telephone", "field.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address.street", "field.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address.postalcode", "field.required");
    }/*  w ww. j  a  v  a  2 s  .c  o m*/
}