Add data validation

On error handle state - currently set data to null.