Example usage for org.springframework.validation Errors reject

List of usage examples for org.springframework.validation Errors reject

Introduction

In this page you can find the example usage for org.springframework.validation Errors reject.

Prototype

void reject(String errorCode, String defaultMessage);

Source Link

Document

Register a global error for the entire target object, using the given error description.

Usage

From source file:ru.org.linux.csrf.CSRFProtectionService.java

public static void checkCSRF(HttpServletRequest request, Errors errors) {
    if (checkCSRF(request)) {
        return;//from www  .ja  va 2  s  . com
    }

    errors.reject(null, "? ?,   ");
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfAlReadyExist(Errors errors, Object data, String errorCode, String errorMsg) {
    if (data != null) {
        errors.reject(errorCode, errorMsg);
    }/*  ww  w. jav  a  2 s .com*/
}

From source file:ru.org.linux.auth.IPBlockDao.java

public static void checkBlockIP(@Nonnull IPBlockInfo block, @Nonnull Errors errors, @Nullable User user)
        throws UnknownHostException, TextParseException {
    if (getTor(block.getIp())) {
        errors.reject(null, "? : tor.ahbl.org");
    }/*from www .j a  v  a2 s  .  c  om*/

    if (block.isBlocked() && (user == null || user.isAnonymousScore() || !block.isAllowRegistredPosting())) {
        errors.reject(null, "? : " + block.getReason());
    }
}

From source file:it.reply.orchestrator.validator.DeploymentRequestValidator.java

@Override
public void validate(Object target, Errors errors) {
    if (target == null) {
        errors.reject("request.null", "Deployment request is null");
        return;/*w  w  w  .  j a va 2  s .  c  o  m*/
    }

    DeploymentRequest deploymentRequest = (DeploymentRequest) target;
    String callbackUrl = deploymentRequest.getCallback();
    if (callbackUrl != null) {
        if (Strings.nullToEmpty(callbackUrl).trim().isEmpty()) {
            errors.rejectValue("callback", "callback.blank", "Callback URL is blank");
        } else {
            try {
                URI.create(callbackUrl).toURL();
            } catch (Exception ex) {
                errors.rejectValue("callback", "callback.malformed", "Callback URL is malformed");
            }
        }
    }
}

From source file:ru.org.linux.auth.FloodProtector.java

public void checkDuplication(String ip, boolean trusted, Errors errors) {
    if (!check(ip, trusted)) {
        errors.reject(null, MESSAGE);
    }//ww w. jav  a2s.c om
}

From source file:org.dspace.app.webui.cris.validator.MailValidator.java

public void validate(Object arg0, Errors arg1) {
    MailDTO dto = (MailDTO) arg0;/*from ww w . j a va 2 s.  c o  m*/
    if (dto.getText() == null || dto.getText().isEmpty()) {
        arg1.reject("error.textmail.mandatory", "Mail text is mandatory");
    }
}

From source file:com.roadrantz.mvc.RantValidator.java

private void validatePlateNumber(String plateNumber, Errors errors) {
    Perl5Util perl5Util = new Perl5Util();
    if (!perl5Util.match(PLATE_REGEXP, plateNumber)) {
        errors.reject("invalid.plateNumber", "Invalid license plate number.");
    }//from w  w w .j  a v  a2  s  . com
}

From source file:net.mindengine.oculus.frontend.service.test.TestValidator.java

@Override
public void validate(Object object, Errors errors) {
    Test test = (Test) object;/*  w  w  w. j a  v  a2  s  .  co  m*/
    if (test.getName() == null || test.getName().isEmpty()) {
        errors.reject(null, "Test name cannot be empty");
    }
}

From source file:net.mindengine.oculus.frontend.service.trm.task.CreateTaskValidator.java

@Override
public void validate(Object obj, Errors err) {
    TrmTask task = (TrmTask) obj;/*from   w  w  w  .  ja v  a2 s.  c  o m*/
    if (task.getName() == null || task.getName().isEmpty()) {
        err.reject(null, "Name shouldn't be empty");
    } else if (task.getProjectId() == null || task.getProjectId() == 0) {
        err.reject(null, "Project is not specified");
    }
}

From source file:net.mindengine.oculus.frontend.service.test.TestGroupValidator.java

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

    TestGroup group = (TestGroup) obj;/*from  w w w . j  a  va 2s  . c o m*/
    if (group.getName() == null || group.getName().isEmpty()) {
        errors.reject(null, "Group name cannot be empty");
    }
}