Package org.javalite.validation
Class Errors
- java.lang.Object
-
- org.javalite.validation.Errors
-
-
Constructor Summary
Constructors Constructor Description Errors()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValidator(String attributeName, Validator validator)Adds a validator whose validation failed.voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,String>>entrySet()Stringget(Object attributeName)Provides a message from a resource bundleactivejdbc_messages.Stringget(String attributeName, Object... params)Provides a message from the resource bundleactivejdbc_messageswhich is merged with parameters.booleanisEmpty()Set<String>keySet()Stringput(String key, String value)voidputAll(Map<? extends String,? extends String> m)Stringremove(Object key)voidsetLocale(Locale locale)Sets a locale on this instance.intsize()StringtoJSON()StringtoString()Collection<String>values()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
addValidator
public void addValidator(String attributeName, Validator validator)
Adds a validator whose validation failed.- Parameters:
attributeName- name of attribute for which validation failed.validator- validator.
-
setLocale
public void setLocale(Locale locale)
Sets a locale on this instance. All messages returned fromget(Object)methods will be returned according to rules of Java Resource Bundles.- Parameters:
locale- locale instance to configure this object.
-
get
public String get(Object attributeName)
Provides a message from a resource bundleactivejdbc_messages. If an there was no validation error generated for the requested attribute, returns null.- Specified by:
getin interfaceMap<String,String>- Parameters:
attributeName- name of attribute in error.- Returns:
- a message from a resource bundle
activejdbc_messagesas configured in a corresponding validator. If an there was no validation error generated for the requested attribute, returns null.
-
get
public String get(String attributeName, Object... params)
Provides a message from the resource bundleactivejdbc_messageswhich is merged with parameters. This methods expects the message in the resource bundle to be parametrized. This message is configured for a validator using a Fluent Interface when declaring a validator:public class Temperature extends Model { static{ validateRange("temp", 0, 100).message("temperature cannot be less than {0} or more than {1}"); } }- Parameters:
attributeName- name of attribute in error.params- list of parameters for a message. The order of parameters in this list will correspond to the numeric order in the parameters listed in the message and has nothing to do with a physical order. This means that the 0th parameter in the list will correspond to{0}, 1st to{1}and so on.- Returns:
- a message from the resource bundle
activejdbc_messageswith default locale, which is merged with parameters.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,String>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,String>
-
toJSON
public String toJSON()
-
-