Added string check before toLowerCase

Calling toLowerCase was causing issues on fields that didn’t have the
type attribute.