Implemented new validation functionality on toJSON.