Tabnine Logo
colesico.framework.validation
Code IndexAdd Tabnine to your IDE (free)

How to use colesico.framework.validation

Best Java code snippets using colesico.framework.validation (Showing top 8 results out of 315)

origin: net.colesico.framework/colesico-validation

public void addSubissue(ValidationIssue subissue) {
  subissues.put(subissue.getSubject(), subissue);
}
origin: net.colesico.framework/colesico-validation

public void addError(String code, String message) {
  ValidationError error = new ValidationError(code, message);
  errors.add(error);
}
origin: net.colesico.framework/colesico-validation

  @Override
  public String toString() {
    StringBuilder eb = new StringBuilder();
    for (ValidationError e : errors) {
      eb.append(e.toString()).append(",\n");
    }

    StringBuilder ib = new StringBuilder();
    for (ValidationIssue vi : subissues.values()) {
      ib.append(vi.toString()).append(",\n");
    }

    return "ValidationIssue : {" +
        "  subject: '" + subject + "',\n" +
        "  errors: {\n" +
        eb.toString() +
        "  \n},\n" +
        "  subissues: {\n" +
        ib.toString() +
        "  \n}\n" +
        '}';
  }
}
origin: net.colesico.framework/colesico-htmlrenderer

private void buildValidationMessages(ValidationIssue issue, String superKey) {
  String key;
  if (StringUtils.isEmpty(superKey)) {
    key = issue.getSubject();
  } else {
    key = superKey + '.' + issue.getSubject();
  }
  for (Map.Entry<String, ValidationIssue> entry : issue.getSubissues().entrySet()) {
    buildValidationMessages(entry.getValue(), key);
  }
  if (issue.hasErrors()) {
    List<String> msgs = new ArrayList<>();
    for (ValidationError ve : issue.getErrors()) {
      msgs.add(ve.getMessage());
    }
    String msg = StringUtils.join(msgs, "; ");
    String msgKey = StringUtils.isEmpty(key) ? VALIDATION_KEY : key;
    messages.put(msgKey, msg);
  }
}
origin: net.colesico.framework/colesico-validation

protected ValidationIssue exportErrors() {
  ValidationIssue issue = new ValidationIssue(getSubject());
  for (ValidationContext childContext : childContexts) {
    ValidationIssue childIssue = childContext.exportErrors();
    if (childIssue != null) {
      issue.addSubissue(childIssue);
    }
  }
  if (hasErrors()) {
    // export errors
    for (ValidationError error : this.errors) {
      issue.addError(error);
    }
    return issue;
  } else if (issue.hasSubissues()) {
    return issue;
  }
  return null;
}
origin: net.colesico.framework/colesico-htmlrenderer

public static Notice error(Exception ex) {
  if (ex instanceof ValidationException) {
    return new Notice(Type.ERROR, ((ValidationException) ex).getIssue());
  }
  if (ex instanceof ApplicationException) {
    return new Notice(Type.ERROR, ex.getMessage());
  }
  return new Notice(Type.ERROR, ExceptionUtils.getRootCauseMessage(ex));
}
origin: net.colesico.framework/colesico-validation

/**
 * Validates the value. Throws exception if validation errors occurred
 *
 * @param value
 * @throws ValidationException if some validation errors occurred
 */
@Override
public void accept(V value) throws ValidationException {
  ValidationContext<V> context = ValidationContext.ofRoot(rootSubject, value);
  rootCommand.execute(context);
  ValidationIssue issue = context.toIssue();
  if (issue != null) {
    throw new ValidationException(issue);
  }
}
origin: net.colesico.framework/colesico-restlet

protected void handleValidationError(ValidationException ex, int httpCode, HttpContext context) {
  String errMsg = MessageFormat.format("Restlet validation error: {0}", ExceptionUtils.getRootCauseMessage(ex));
  log.error(errMsg);
  RestletErrorResponse response = new RestletErrorResponse(context.getRequest().getRequestURI(), httpCode, ex.getIssue());
  restletDataPort.sendError(response, httpCode);
}
colesico.framework.validation

Most used classes

  • ValidationException
  • ValidationError
  • ValidationIssue
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now