Class ValidationUtils


  • public final class ValidationUtils
    extends Object
    Helper methods for validating objects and generating JSON schemas.
    Author:
    Alex Bogdanovski [alex@erudika.com]
    • Method Detail

      • getValidator

        public static javax.validation.Validator getValidator()
        A Hibernate Validator.
        Returns:
        a validator object
      • isValidObject

        public static boolean isValidObject​(ParaObject obj)
        Validates objects using Hibernate Validator. Used for basic validation.
        Parameters:
        obj - an object to be validated
        Returns:
        true if the object is valid (all fields are populated properly)
      • isValidObject

        public static boolean isValidObject​(App app,
                                            ParaObject obj)
        Validates objects using Hibernate Validator. Used for full object validation.
        Parameters:
        app - the current app
        obj - an object to be validated
        Returns:
        true if the object is valid (all fields are populated properly)
      • validateObject

        public static String[] validateObject​(ParaObject content)
        Validates objects using Hibernate Validator.
        Parameters:
        content - an object to be validated
        Returns:
        a list of error messages or empty if object is valid
      • validateObject

        public static String[] validateObject​(App app,
                                              ParaObject content)
        Validates objects.
        Parameters:
        content - an object to be validated
        app - the current app
        Returns:
        a list of error messages or empty if object is valid
      • getCoreValidationConstraints

        public static Map<String,​Map<String,​Map<String,​Map<String,​?>>>> getCoreValidationConstraints()
        Returns all validation constraints that are defined by Java annotation in the core classes.
        Returns:
        a map of all core types to all core annotated constraints. See JSR-303.