/** * @param field The field name * @return true if field has some errors */ public static boolean hasErrors(String field){ return error(field) != null; }
/** * @param field The field name * @return True is there are errors related to this field */ public static boolean hasError(String field) { return error(field) != null; }
public Error forKey(String key) { return Validation.error(key); }
/** * Insert an error at the specified position in this list. * @param index index at which the specified element is to be inserted * @param field Field name * @param message Message key * @param variables Message variables */ public static void insertError(int index, String field, String message, String... variables) { Error error = error(field); if (error == null || !error.message.equals(message)) { Validation.current().errors.add(index, new Error(field, message, variables)); } }
public static void _error(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) { if (args.get("arg") == null && args.get("key") == null) { throw new TemplateExecutionException(template.template, fromLine, "Please specify the error key", new TagInternalException( "Please specify the error key")); } String key = args.get("arg") == null ? args.get("key") + "" : args.get("arg") + ""; Error error = Validation.error(key); if (error != null) { if (args.get("field") == null) { out.print(error.message()); } else { out.print(error.message(args.get("field") + "")); } } }
field.put("flashArray", field.get("flash") != null && !StringUtils.isEmpty(field.get("flash").toString()) ? field.get("flash") .toString().split(",") : new String[0]); field.put("error", Validation.error(_arg)); field.put("errorClass", field.get("error") != null ? "hasError" : ""); String[] pieces = _arg.split("\\.");