public static String [ ] validateObject ( App app , ParaObject content ) { if ( content == null || app == null ) { return new String [ ] { "Object cannot be null." } ; } try { String type = content . getType ( ) ; boolean isCustomType = ( content instanceof Sysprop ) && ! type . equals ( Utils . type ( Sysprop . class ) ) ; // Validate custom types and user-defined properties if ( ! app . getValidationConstraints ( ) . isEmpty ( ) && isCustomType ) { Map < String , Map < String , Map < String , ? > > > fieldsMap = app . getValidationConstraints ( ) . get ( type ) ; if ( fieldsMap != null && ! fieldsMap . isEmpty ( ) ) { LinkedList < String > errors = new LinkedList <> ( ) ; for ( Map . Entry < String , Map < String , Map < String , ? > > > e : fieldsMap . entrySet ( ) ) { String field = e . getKey ( ) ; Object actualValue = ( ( Sysprop ) content ) . getProperty ( field ) ; // overriding core property validation rules is allowed if ( actualValue == null && PropertyUtils . isReadable ( content , field ) ) { actualValue = PropertyUtils . getProperty ( content , field ) ; } Map < String , Map < String , ? > > consMap = e . getValue ( ) ; for ( Map . Entry < String , Map < String , ? > > constraint : consMap . entrySet ( ) ) { buildAndValidateConstraint ( constraint , field , actualValue , errors ) ; } } if ( ! errors . isEmpty ( ) ) { return errors . toArray ( new String [ 0 ] ) ; } } } } catch ( Exception ex ) { logger . error ( null , ex ) ; } return validateObject ( content ) ; }
Validates objects .