check if value is actually valid before attempting to store

This is to handle cases when `null` is passed as a value:

```javascript
{
 "key" :  null
}
```