Fixed callback invocation
Removed code duplication
Renamed method name + removed code duplication
Added additional condition to distinguish cases with collections
Corrected generated error message
Added checking for correct validator definition
Refactored code