play.data.validation.ValidationError Java Examples
The following examples show how to use
play.data.validation.ValidationError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Application.java From pay with Apache License 2.0 | 5 votes |
protected static boolean validateForm(Form form){ Map errors = form.errors(); Iterator it = errors.values().iterator(); if(it.hasNext()){ List<ValidationError> error = (List<ValidationError>) it.next(); throw new RuntimeException(error.get(0).message()); }else return true; }
Example #2
Source File: Group.java From htwplus with MIT License | 5 votes |
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (GroupManager.findByTitle2(this.title) != null) { errors.add(new ValidationError("title", "error.title")); return errors; } return null; }
Example #3
Source File: PlayJavaFormResolver.java From commercetools-sunrise-java with Apache License 2.0 | 4 votes |
private ErrorViewModel createError(final ValidationError error) { final ErrorViewModel errorViewModel = new ErrorViewModel(); errorViewModel.setMessage(errorFormatter.format(error)); return errorViewModel; }
Example #4
Source File: ErrorFormatter.java From commercetools-sunrise-java with Apache License 2.0 | 2 votes |
/** * Formats the Play error message somehow. * @param error Play's validation error * @return the error message localized and formatted */ default String format(final ValidationError error) { final String message = format(error.message()); return !error.key().isEmpty() ? message + ": " + error.key() : message; }