Bugfix: Check constraint before loop

Check if the field has a constraint, before going into a foreach loop.