- java.lang.Object
- 
- org.omnifaces.util.Validators
 
- 
 public final class Validators extends Object Collection of utility methods for the Bean Validation API in general. UsageHere are some examples: // Check if Bean Validation is available. boolean available = Validators.isBeanValidationAvailable(); // Check if Bean Validation is available. boolean available = Validators.isBeanValidationAvailable(); // Validate whole bean with Bean Validation. Set<ConstraintViolation<?>> violations = Validators.validateBean(bean); // Validate only a bean property with Bean Validation. Set<ConstraintViolation<?>> violations = Validators.validateBeanProperty(bean, "propertyName", propertyValue); For a full list, check the method summary. - Since:
- 3.8
- Author:
- Bauke Scholtz, Andre Wachsmuth
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringBEAN_VALIDATION_AVAILABLE
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static ValidatorgetBeanValidator()Returns the bean validator which is aware of the Faces locale.static ValidatorFactorygetBeanValidatorFactory()Returns the default bean validator factory.static List<Path.Node>getPropertyNodes(ConstraintViolation<?> violation)Returns a list of property path nodes from the given constraint violation.static booleanisBeanValidationAvailable()Returnstrueif Bean Validation is available.static ObjectresolveViolatedBase(Object bean, ConstraintViolation<?> violation)Resolve violated base from given bean based on given violation.static List<Map.Entry<Object,String>>resolveViolatedBasesAndProperties(Object bean, ConstraintViolation<?> violation)Resolve violated bases and properties from given bean based on given violation in reverse order.static StringresolveViolatedProperty(ConstraintViolation<?> violation)Resolve violated property from given violation.static Set<ConstraintViolation<?>>validateBean(Object bean, Class<?>... groups)Validate given bean on given group classes.static Set<ConstraintViolation<?>>validateBeanProperty(Class<?> beanType, String propertyName, Object value, Class<?>... groups)Validate given value as if it were a property of the given bean type.
 
- 
- 
- 
Field Detail- 
BEAN_VALIDATION_AVAILABLEpublic static final String BEAN_VALIDATION_AVAILABLE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
isBeanValidationAvailablepublic static boolean isBeanValidationAvailable() Returnstrueif Bean Validation is available. This is remembered in the application scope.- Returns:
- trueif Bean Validation is available.
 
 - 
getBeanValidatorFactorypublic static ValidatorFactory getBeanValidatorFactory() Returns the default bean validator factory. This is remembered in the application scope.- Returns:
- The default bean validator factory.
 
 - 
getBeanValidatorpublic static Validator getBeanValidator() Returns the bean validator which is aware of the Faces locale.- Returns:
- The bean validator which is aware of the Faces locale.
- See Also:
- Faces.getLocale()
 
 - 
validateBeanpublic static Set<ConstraintViolation<?>> validateBean(Object bean, Class<?>... groups) Validate given bean on given group classes.- Parameters:
- bean- Bean to be validated.
- groups- Bean validation groups, if any.
- Returns:
- Constraint violations.
 
 - 
validateBeanPropertypublic static Set<ConstraintViolation<?>> validateBeanProperty(Class<?> beanType, String propertyName, Object value, Class<?>... groups) Validate given value as if it were a property of the given bean type.- Parameters:
- beanType- Type of target bean.
- propertyName- Name of property on target bean.
- value- Value to be validated.
- groups- Bean validation groups, if any.
- Returns:
- Constraint violations.
 
 - 
resolveViolatedBasepublic static Object resolveViolatedBase(Object bean, ConstraintViolation<?> violation) Resolve violated base from given bean based on given violation.- Parameters:
- bean- Bean to resolve violated base on.
- violation- Constraint violation to resolve violated base from.
- Returns:
- Violated base from given bean based on given violation.
 
 - 
resolveViolatedBasesAndPropertiespublic static List<Map.Entry<Object,String>> resolveViolatedBasesAndProperties(Object bean, ConstraintViolation<?> violation) Resolve violated bases and properties from given bean based on given violation in reverse order.- Parameters:
- bean- Bean to resolve violated base on.
- violation- Constraint violation to resolve violated base from.
- Returns:
- Violated bases and properties from given bean based on given violation in reverse order.
- Since:
- 3.14.2
 
 - 
resolveViolatedPropertypublic static String resolveViolatedProperty(ConstraintViolation<?> violation) Resolve violated property from given violation.- Parameters:
- violation- Constraint violation to resolve violated property from.
- Returns:
- Violated property from given violation.
 
 - 
getPropertyNodespublic static List<Path.Node> getPropertyNodes(ConstraintViolation<?> violation) Returns a list of property path nodes from the given constraint violation.- Parameters:
- violation- The constraint violation to return a list of property path nodes from.
- Returns:
- A list of property path nodes from the given constraint violation.
 
 
- 
 
-