I have the following status of my application.

```
const [errors, setErrors] = useState({});

```

when i try to store the errors it returns validating in hook state the values ​​are replaced and only the last one is stored

```
 for (const key in book) {

            if (key == 'category_id') {
                val = validating('category', book[key], categories);
            } else {
                val = validating(key, book[key]);
            }

            console.log(key + ':' + val.status)
            setErrors({ ...errors, [key]: val });
            //console.log(errors)
        }

```

The validating function returns {status: true} or {message:'error', status:'false'}

the validation function works fine, the problem is that the objects returned by validating are not accumulated